Node.js 4.0.0 is out - quick tip for use while testing compatibility

By: (plus.google.com) +David Herron; Date: 2015-09-09 17:58

Tags: Node.JS » JavaScript

Node.js v 4.0.0 was just released. This is a long-awaited release representing the healing of the schism in the Node.js community created when the io.js project forked Node.js. That had been done over a disagreement about the policies and maintainership of Node.js. Joyent had been in control of the project (because Ryan Dahl had been employed by Joyent) and not all in the community liked the decisions made by Joyent. They instead forked the project to create io.js, and implemented a bunch of useful ideas for example to adopt the latest-and-greatest version of the V8 JavaScript engine in order to get all the modern ES6 goodies.

A few months ago the Node.js and io.js teams came to an agreement. A new Foundation would be created, co-sponsored by a bunch of companies, to oversee Node.js. The workspaces would be merged so that there'd be just the Node.js workspace, and not Node.js/io.js as separate workspaces. And so on.

Releasing Node.js 4.0.0 means the community reached that milestone of merging the repositories and issuing a stable release.

For the rest of us that means we now need to test compatibility of our code with Node.js 4.0.0.

That's what I set about doing earlier today, checking my code for compatibility. It was great to run (akashacms.com) AkashaCMS to rebuild one of my sites while using 4.0.0, and see it work flawlessly. But then I set about checking the code for my book, Node Web Development, and ran into a problem.

Some of the example code uses the SQLite3 and LevelDOWN database engines. Unfortunately both of those engines failed. But I figured out what to do instead.

For the purpose of checking compatibility, I'd installed Node.js 4.0.0 in /usr/local/node-v4.0.0-linux-x64. This is Ubuntu, and I have Node v0.10.x installed as a regular system package. That package is still installed as the official Node binary for the system. I didn't want to change that, and instead wanted to simply kick the tires of 4.0.0.

To run the code for my book, I did this:

 $  rm -rf node_modules/
 $  /usr/local/node-v4.0.0-linux-x64/bin/npm install
 $  /usr/local/node-v4.0.0-linux-x64/bin/node app.js

For most code this worked. However, the code which relied on SQLite3 or LevelDOWN failed. It was puzzling, and I even filed some bugs with those two project teams.

In one case, SQLite3, they'd been working on an update for 4.0.0 compatibility and had recently published an update for that purpose. But the LevelDOWN guys gave me an idea to do this:

$ export PATH=/usr/local/node-v4.0.0-linux-x64/bin:${PATH}

That then let me run the commands this way:

 $  rm -rf node_modules/
 $  npm install
 $  node app.js

Now my code works perfectly with no change. This is code that'd been written back in 2013 and had been published, on paper, in my book, so the code had better work as it's written in the book.

What's different from changing the PATH as I did? It would mean that internally to npm install there's a dependency on running a command line node something-or-other to install some things. In particular, SQLite3 and LevelDOWN both build platform-specific binary modules and therefore npm has to invoke the correct build tool.

By changing the PATH, I've ensured that when npm invokes a command line tool it's invoked relative to the correct PATH variable.

The tip: Go ahead and unpack the Node.js 4.0.0 distribution in a secondary location like this. Make sure to prepend that location to your PATH variable.

« How does Node.js compare to a traditional MVC platform like Spring? The difference between Node.js require, and Wordpress plugins or Drupal modules »
2016 Election Acer C720 Ad block AkashaCMS Amazon Amazon Kindle Amiga Android Anti-Fascism AntiVirus Software Apple Apple Hardware History Apple iPhone Apple iPhone Hardware April 1st Arduino ARM Compilation Astronomy Asynchronous Programming Authoritarianism Automated Social Posting Ayo.JS Bells Law Big Brother Big Finish Bitcoin Mining Black Holes Blade Runner Blockchain Blogger Blogging Books Botnet Botnets Cassette Tapes Cellphones Christopher Eccleston Chrome Chrome Apps Chromebook Chromebooks Chromebox ChromeOS CIA CitiCards Citizen Journalism Civil Liberties Clinton Cluster Computing Command Line Tools Computer Hardware Computer Repair Computers Cross Compilation Crouton Cryptocurrency Curiosity Rover Cyber Security Cybermen Daleks Darth Vader Data backup Data Storage Database Database Backup Databases David Tenant DDoS Botnet Detect Adblocker Developers Editors Digital Photography Diskless Booting DIY DIY Repair DNP3 Do it yourself Docker Docker Swarm Doctor Who Doctor Who Paradox Drobo Drupal Drupal Themes DVD E-Books E-Readers Early Computers Election Hacks Electric Bicycles Electric Vehicles Electron Emdebian Encabulators Energy Efficiency Enterprise Node EPUB ESP8266 Ethical Curation Eurovision Event Driven Asynchronous Express Facebook Fake News Fedora VirtualBox File transfer without iTunes FireFly Fraud Freedom of Speech Gallifrey git Gitlab GMAIL Google Google Chrome Google Gnome Google+ Government Spying Great Britain Heat Loss Hibernate Hoax Science Home Automation HTTPS Human ID I2C Protocol Image Analysis Image Conversion Image Processing ImageMagick InfluxDB Infrared Thermometers Insulation Internet Internet Advertising Internet Law Internet of Things Internet Policy Internet Privacy iOS Devices iPad iPhone iPhone hacking Iron Man Iternet of Things iTunes Java JavaScript JavaScript Injection JDBC John Simms Journalism Joyent Kaspersky Labs Kindle Marketplace Lets Encrypt LibreOffice Linux Linux Hints Linux Single Board Computers Logging Mac OS Mac OS X Machine Readable ID MacOS X setup Make Money Online MariaDB Mars Matt Lucas MEADS Anti-Missile Mercurial Michele Gomez Micro Apartments Military Hardware Minification Minimized CSS Minimized HTML Minimized JavaScript Missy Mobile Applications MODBUS Mondas MongoDB Mongoose Monty Python MQTT Music Player Music Streaming MySQL NanoPi Nardole NASA Net Neutrality Node Web Development Node.js Node.js Database Node.js Testing Node.JS Web Development Node.x North Korea Online advertising Online Fraud Online Journalism Online Video Open Media Vault Open Source Governance Open Source Licenses Open Source Software OpenAPI OpenVPN Personal Flight Peter Capaldi Photography PHP Plex Plex Media Server Political Protest Postal Service Power Control Privacy Production use Public Violence Raspberry Pi Raspberry Pi 3 Raspberry Pi Zero Recycling Remote Desktop Republicans Retro-Technology Reviews Right to Repair River Song Robotics Rocket Ships RSS News Readers rsync Russia Russia Troll Factory Russian Hacking SCADA Scheme Science Fiction Search Engine Ranking Season 1 Season 10 Season 11 Security Security Cameras Server-side JavaScript Shell Scripts Silence Simsimi Skype Social Media Social Media Warfare Social Networks Software Development Space Flight Space Ship Reuse Space Ships SpaceX Spear Phishing Spring Spring Boot SQLite3 SSD Drives SSD upgrade SSH SSH Key SSL Swagger Synchronizing Files Telescopes Terrorism The Cybermen The Daleks The Master Time-Series Database Torchwood Total Information Awareness Trump Trump Administration Trump Campaign Ubuntu UDOO Virtual Private Networks VirtualBox VLC VNC VOIP Web Applications Web Developer Resources Web Development Web Development Tools Web Marketing Website Advertising Weeping Angels WhatsApp Window Insulation Wordpress YouTube YouTube Monetization