Introduction to Node.js version management library n
February 13, 2022
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:
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 nor
npm i -g nYou can clone the repo and use make install to install it.
On mac, it is available to install from HomeBrew and MacPorts.
brew install nor
port install nAlso, n-install allows to install it directly from Github on MacOS and Linux:
curl -L https://git.io/n-install | bashHow 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 bin, include, lib and share.
Install a specific version:
Use n
n 14.15You might need to use sudo:
sudo n 14.15Or, you can use n to check the downloaded versions and switch between the versions using the arrow keys.
Numeric versions:
Specify the complete version name or the primary version name:
n v14.15.5
n 14.15
n 14 // for 14.x.y
n 14.1 // for 14.1.xLabels:
You can use labels to install specific versions:
n lts // newest lts release
n latest // newest official release
n current // newest official releaseor for named release streams:
n argon
n boron
n carbonn nightly
n test/x.y.z
n rc/5Remove version:
Remove cached versions:
n 14.15 14.15.1Remove all cached versions except the install one:
n pruneRemove the installed Node.js
n uninstallCheck downloaded Node.js path:
Run the below command to check the downloaded Node.js path:
n which 13.1You can use any downloaded version to run a js file:
n run 14.15 --debug example.jsOther commands:
Help:
n --helpShow all downloaded versions:
n lsShow diagnostics to solve issues:
n doctor