Developing with node and iojs

by Evan Lucas, 2015-05-13

Recently, I've seen a few people asking about running both node.js and iojs concurrently, especially during the development lifecycle of an application. There are a couple of routes that one can take to accomplish this.

node-bin / iojs-bin

Both node-bin and iojs-bin are packages on the npm registry. They can be installed like any other package.

$ npm install --save node-bin
# or 
$ npm install --save iojs-bin

Say you wanted to use node on this particular project. In your package.json, you could create a start script like so:

{
  "name": "project",
  "version": "1.0.0",
  "scripts": {
    "start": "./node_modules/.bin/node index.js"
  }
}

To use iojs, simply change your package.json to look something like:

{
  "name": "project",
  "version": "1.0.0",
  "scripts": {
    "start": "./node_modules/.bin/iojs index.js"
  }
}

Thanks to @aredridel for node-bin and iojs-bin!


nvm

A slightly different solution to solve this problem would be to use a version manager like nvm. One can follow the instructions in the readme to install nvm.

First, install a version of node:

$ nvm install 0.12

Then, install a version of iojs:

$ nvm install iojs

To activate one of the versions:

$ nvm use iojs
# or 
$ nvm use 0.10

n

Being that my preferred shell is fish and nvm does not work with fish, I had to explore other alternatives. Enter n.

n is similar to nvm in some ways, but it actually works with fish.

To install n:

$ npm install -g n

n has very similar commands to nvm. Running n without any arguments will show a list of available versions to install or activate.

To install the latest version of node:

$ n latest

To install the latest version of iojs:

$ n io latest

That wraps it up. If you have any questions/comments/issues, please feel free to reach out to me on Twitter (@evanhlucas) or check out my GitHub (@evanlucas).