I have a problem understanding the use of n. Basically, it is clear that it is a version manager for Node.js such as nvm.
But in contrast to nvm, which is basically a shell script, according to the documentation you are encouraged to use npm to install n:
$ npm install -g n
# Install n and the latest stable Node.js version to ~/n. # For bash, ksh, zsh, modify the relevant shell-initialization file to # define env. variable N_PREFIX and append $N_PREFIX/bin to the $PATH. curl -L https://git.io/n-install | bash
I feel your pain. Installing Node.js to then install
n to then manage Node.js installations is indeed a strange setup.
It would indeed be great to be able to install
n by itself first.
I've created a project to support installation of
n directly from GitHub; the only prerequisite beyond what
n itself needs is
Note that you must first remove any pre-existing
n / Node.js versions.
The target directory,
~/n by default, must either not yet exist or be empty.
zsh, the relevant shell initialization file (e.g.,
~/.bashrc) is automatically modified to define environment variable
N_PREFIX and append
$N_PREFIX/bin to the
$PATH; for other shells, this must be done manually.
Aside from installing
n directly from GitHub, it also installs helper scripts for updating
n-update) and uninstalling it (
Here are working examples; see the n-install GitHub repo for details:
Installation with confirmation prompt to confirm installing to default location
$HOME/n and installing the latest stable Node.js version:
curl -L https://git.io/n-install | bash
Automated installation to the default location, with subsequent installation of the latest LTS (long-term support) and stable Node.js versions, as well as the latest 4.1.x Node.js version:
curl -L https://git.io/n-install | bash -s -- -y lts stable 4.1
Automated installation to the default location, without subsequent installation of the latest stable Node.js version:
curl -L https://git.io/n-install | bash -s -- -y -
Automated installation to custom location
~/util/n, with subsequent installation of the latest stable Node.js version:
curl -L https://git.io/n-install | N_PREFIX=~/util/n bash -s -- -y