How to use n to handle node versions:
n is a Node.js version management library. It is simple to use and it makes easier to switch between Node.js versions quickly.
In this post, I will show you how to install it and how to use it with different examples.
n library is used to manage Node.js versions. You can install any Node.js version on your system, switch between current installed version quickly, etc.
Where it is supported:
n works on linux, macOS and windows subsystem for linux including other unix like systems. It doesn’t work in native shell for windows, Git for windows bash or with Cygwin DLL.
How to install n:
You can install n using npm. If npm is installed on your system, you can use the below command to install it:
npm install -g n
npm i -g n
You can clone the repo and use
make install to install it.
On mac, it is available to install from HomeBrew and MacPorts.
brew install n
port install n
Also, n-install allows to install it directly from Github on MacOS and Linux:
curl -L https://git.io/n-install | bash
How to install a Node.js version using n:
n caches Node.js versions in subdirectory n/versions. By default, you will find it in /usr/local/n/versions. This makes the reinstall fast. The active version is installed in
Install a specific version:
You might need to use sudo:
sudo n 14.15
Or, you can use
n to check the downloaded versions and switch between the versions using the arrow keys.
Specify the complete version name or the primary version name:
n 14 // for 14.x.y
n 14.1 // for 14.1.x
You can use labels to install specific versions:
n lts // newest lts release
n latest // newest official release
n current // newest official release
or for named release streams:
Remove cached versions:
n 14.15 14.15.1
Remove all cached versions except the install one:
Remove the installed Node.js
Check downloaded Node.js path:
Run the below command to check the downloaded Node.js path:
n which 13.1
You can use any downloaded version to run a js file:
n run 14.15 --debug example.js
Show all downloaded versions:
Show diagnostics to solve issues: