NodeJs versions manager

Developing NodeJS nowadays, you find yourself required to move between different versions of node either because you have old apps using previous versions of node, wanna try out new stuff with the latest version (v10.5) or develop new stuff using the recommended version (v 8.11).

There are several ways to switch between node versions including using OSX version managers like homebrew or macports, or more specific like nvm, nave or n.

While trying some of them, my current favourite is ’n’ (https://github.com/tj/n) and that’s due to the reason that it provide a steady path instead of juggling paths around, which helps when your IDE like WebStorm requires a steady path to node binaries.

Install

you can install n using NPM, because its already install on your system, but I preferred to start out clean and first I removed node & npm I already had installed and used 3rd party n-installer to install n.

curl -L https://git.io/n-install | bash

NOTE: now either write . ~/.bash_profile in bash or open a new terminal to have n available in command line.

As a result, both n itself and all node versions it manages are hosted inside a single directory.

This also installs latest version of node for you.

n ls – provides a list of versions available to install

you can quickly run the following commands, to have a bunch of useful versions installed:

n latest
n stable
n lts
n 4.9.1 # (or a more specific version)

enter n in the terminal, will allow you to select the version you want to activate.

Removing all version except the latest use:

n prune

To get help write

n -h

Published
Categorized as Setup