Node.js/IO.js/npm setup

See http://stackoverflow.com/questions/10081293/install-npm-into-home-directory-with-distribution-nodejs-package-ubuntu for the followings, which basically mean I can npm install -g without worrying anymore:

export NPM_PACKAGES="$HOME/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"

And then I use:

export PATH="$PATH:./node_modules/.bin:$NPM_PACKAGES/bin"

Notice ./node_modules/.bin which is a relative PATH entry, which is normally not recommended… but allows you to use tools (mocha, ..) installed by npm when running from the root directory of a package. Totally worth it.

n

I use n to manage node versions.

export N_PREFIX=$HOME/.local
Written on March 9, 2015