Node - install selected Node.js and nvm version under Debian / Ubuntu
In this short article, we would like to show how to install desired version of the Node.js or npm under Linux.
Warning: node will be installed per specific user only!
Quick solution:
# apt-get update
# apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install v16.0.0
nvm use v16.0.0
node -v
Detailed instruction
Node: using below instruction we are able to switch between existing Node.js versions (
npm
versions too) - just go to step 4 in the below instruction.
Simple steps:
1. we need to download and install nvm
script that let's to switch Node.js versions
1.1. install curl
command only if you don't have it instelled yet:.
apt-get install curl
1.2. install nvm
command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Note: check the last version on https://github.com/nvm-sh/nvm.
1.3 reload enviroment variables to have access to nvm
command (or you can just restart your Linux):
source ~/.bashrc
2. check avaialble Node.js versions:
nvm ls-remote
Example output:
...
v15.3.0
v15.4.0
v15.5.0
...
v15.14.0
v16.0.0
v16.1.0
...
v16.9.1
v16.10.0
v16.11.0
...
3. install selected Node.js version:
nvm install v16.0.0
Example output:
Downloading and installing node v16.0.0...
Downloading https://nodejs.org/dist/v16.0.0/node-v16.0.0-linux-x64.tar.xz...
######################################################################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.0.0 (npm v7.10.0)
Creating default alias: default -> v16.0.0
4. set installed Node.js as used/active one (this command can be executed on instaled versions before):
nvm use v16.0.0
Example output:
Now using node v16.0.0 (npm v7.10.0)
5. check Node.js and npm versions:
$ node -v
v16.0.0
$ npm -v
7.10.0
See also
Alternative titles
- Node - switch nodejs and nvm version under Debian / Ubuntu
- Node - switch Node.js version under Debian / Ubuntu (nvm switching)
- Node - change nodejs and nvm version under Debian / Ubuntu
- Node - install desired Node.js and nvm version under Debian / Ubuntu
- Node - install desired nodejs and nvm version under Debian / Ubuntu