Node.js : Install version management tool2023/07/14 |
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 18.16.1 # show the [latest] version root@dlp:~# n --latest 20.4.0 # install the [stable] version root@dlp:~# n stable installing : node-v18.16.1 mkdir : /usr/local/n/versions/node/18.16.1 fetch : https://nodejs.org/dist/v18.16.1/node-v18.16.1-linux-x64.tar.xz copying : node/18.16.1 installed : v18.16.1 (with npm 9.5.1) 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:~#
/usr/local/bin/node -v v18.16.1 # install the [latest] version root@dlp:~# n latest installing : node-v20.4.0 mkdir : /usr/local/n/versions/node/20.4.0 fetch : https://nodejs.org/dist/v20.4.0/node-v20.4.0-linux-x64.tar.xz copying : node/20.4.0 installed : v20.4.0 (with npm 9.7.2)
root@dlp:~#
/usr/local/bin/node -v v20.4.0 # show installed versions root@dlp:~# n ls node/18.16.1 node/20.4.0 # switch to another version root@dlp:~# n node/18.16.1 copying : node/18.16.1 installed : v18.16.1 (with npm 9.5.1)
root@dlp:~#
/usr/local/bin/node -v v18.16.1 # deb package installed Node.js root@dlp:~# /usr/bin/node -v v18.13.0 |
Sponsored Link |