Ubuntu 22.04
Sponsored Link

Node.js : Install version management tool2022/08/26

 
Install Node.js version management tool [n] command.
[1]
[2] Install [n] command and upgrade Node.js.
root@dlp:~#
npm install -g n

added 1 package, and audited 2 packages in 798ms

found 0 vulnerabilities

# show the [stable] version

root@dlp:~#
n --stable

16.17.0
# show the [latest] version

root@dlp:~#
n --latest

18.8.0
# install the [stable] version

root@dlp:~#
n stable

  installing : node-v16.17.0
       mkdir : /usr/local/n/versions/node/16.17.0
       fetch : https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz
     copying : node/16.17.0
   installed : v16.17.0 (with npm 8.15.0)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
If "node --version" shows the old version then start a new shell, or reset the location hash with:
hash -r  (for bash, zsh, ash, dash, and ksh)
rehash   (for csh and tcsh)

root@dlp:~#
node -v

v16.17.0
# install the [latest] version

root@dlp:~#
n latest

  installing : node-v18.8.0
       mkdir : /usr/local/n/versions/node/18.8.0
       fetch : https://nodejs.org/dist/v18.8.0/node-v18.8.0-linux-x64.tar.xz
     copying : node/18.8.0
   installed : v18.8.0 (with npm 8.18.0)

root@dlp:~#
node -v

v18.8.0
# show installed versions

root@dlp:~#
n ls

node/16.17.0
node/18.8.0

# switch to another version

root@dlp:~#
n node/16.17.0

     copying : node/16.17.0
   installed : v16.17.0 (with npm 8.15.0)

root@dlp:~#
node -v

v16.17.0
# deb package installed Node.js

root@dlp:~#
/usr/bin/node -v

v12.22.9
Matched Content