n - Interactively Manage Your Node.js Versions on macOS

 n  is a Node.js version management: no sub-shells, no profile setup, no convoluted, just simple.

Supported Platforms

 n  is supported on macOS, Linux, including with Windows Subsystem for Linux, and various other unix-like systems. It is written as a BASH script but does not require you to use BASH as your command shell.

 n  does not work in native shells on Microsoft Windows (like PowerShell), or Git for Windows BASH, or with the Cygwin DLL.

Installation

If you already have Node.js installed, an easy way to install  n  is using  npm :

sudo npm install -g n

The  n  command downloads and installs to  /usr/local  by default.

Installing Node.js Versions

Simply execute  n  <version>  to download and install a version of Node.js. If  <version>  has already been downloaded,  n  will install from its cache.

sudo n 10.16.0
sudo n 10

sudo n install 10

sudo n lts
sudo n latest

Execute  n  on its own to view your downloaded versions, and installed the selected version.

% sudo n

  node/12.22.8
  node/16.13.1
ο node/8.11.3

  node/17.3.0


Use up/down arrow keys to select a version, return key to install, d to delete, q to quit


If the active node version does not change after install, try opening a new shell in case seeing a stale version.


Removing Node.js Versions

Remove the given downloaded/cached versions:

sudo n rm 10


Remove all downloaded/cached versions except the installed version:


sudo n prune

Remove the installed Node.js (does not affect the cached versions). This can be useful to revert to the system version of node (if in a different location), or if you no longer wish to use node and npm, or are switching to a different way of managing them.

sudo n uninstall

To Know the path of the downloaded  node  version:

You can show the path of the downloaded  node  version:


% n which 12.22.8

/usr/local/n/versions/node/12.22.8/bin/node


Using Downloaded Node.js Versions Without Reinstalling

Command for working directly with your downloaded versions of Node.js, without reinstalling.


% n run 12.22.8


Miscellaneous

Display downloaded Node.js versions and install selection:


 sudo n 


Install the latest Node.js release:


 sudo n latest 


Install the latest LTS Node.js release:


 sudo n lts 


Output downloaded versions:


 n ls 


Output the latest Node.js version available:


 n --latest 

Output the latest LTS Node.js version available:

 n --lts 

Display diagnostics to help resolve problems:


 n doctor 

Output version of n:


 n -V, n --version 


Display help information:


 n -h, n --help 


If you already have Node.js installed, an easy way to uninstall  is using  npm  else you first install Node.js is using  n :

 sudo npm uninstall -g n 



The End

Comments

Popular posts from this blog