Languages
[Edit]
EN

Node - install selected Node.js and nvm version under Debian / Ubuntu

4 points
Created by:
GamerGoals22
364

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

  1. Node.js - install selected Node.js version under Windows

Alternative titles

  1. Node - switch nodejs and nvm version under Debian / Ubuntu
  2. Node - switch Node.js version under Debian / Ubuntu (nvm switching)
  3. Node - change nodejs and nvm version under Debian / Ubuntu
  4. Node - install desired Node.js and nvm version under Debian / Ubuntu
  5. Node - install desired nodejs and nvm version under Debian / Ubuntu
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join