Languages
[Edit]
EN

Node - switch Node.js and mvn version under Linux

4 points
Created by:
GamerGoals22
274

In this short article, we would like to show how to install desired version of the Node.js or npm under Linux.

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 mvn 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

 

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