FrontEnd web
Published in

FrontEnd web

What is nvm, and How do you install nodejs with the nvm command?
Install nodejs version with nvm command.

What is nvm, and How do you install nodejs with the nvm command?

NVM is a bash script to manage multiple node.js versions on the machine.

Node version manager (NVM) is a bash script that helps to manage multiple active node.js versions of nodejs on your machine.

It is a command line utility for Windows, macOS, and Linux. In Linux, nvm is available for everyone distro. Therefore, you do not need to install other utilities to work with nvm.

How to install nvm in Linux?

For installation, you run the following bash command in your terminal, and your nvm installation process starts.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

the output of command —

How to install nvm command in Linux?
install nvm in Linux

The most important part is to verify the configuration of nvm. ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc . If the configuration is not added automatically on installation time. You add manually config the nvm open of ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc file. my recommendation is ~/.bash_profile . You open ~/.bash_profile file with any IDE and paste the following code into ~/.bash_profile .

Maybe the config is different according to your distro. You're the config shown in the terminal on installation time.

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

After config the nvm config in the bash file now you close and reopen your terminal to start using nvm or run the following command.

How to install nodejs with nvm?

NVM provide a lot of in-built commands to install nodejs with one click. The most important command is nvm --help a command. It prints all available commands in your terminal.

To install the latest version of nodejs and set the default version. For that, you run two commands.

nvm install node  // you install latest version of nodejs        
nvm use node // you set default latest version of nodejs
Install nodejs latest version with nvm command
Install nodejs latest version with nvm

Most of the time, we install the nodejs(LTS) version on our laptop. for that, you run the following two commands.

nvm install --lts   // Install the latest LTS version
nvm use --lts // you set default lts version.
install nodejs LTS version with nvm command
Install nodejs LTS version with nvm command

Suppose you are interested in downloading a specific nodejs version on the machine. Then, you can also do that.

nvm install 12.0.2 // install nodejs 12.0.2 version
nvm set 12.0.2 // set the default version of nodejs with use

How to delete the nodejs version with nvm?

nvm uninstall node  // delete latest version of node
nvm uninstall --lts // with --lts flag you uninstall the LTS
nvm uninstall 12.0.2 // uninstall with version

Conclusion

NVM is the best node version manager. With nvm, you install a different type of nodejs version in the machine and maintain them.

You can share and follow on Twitter and Linkedin. If you like my work, please read more content on the officialrajdeepsingh. dev, frontend web, and sign up for a free newsletter on frontend web.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rajdeep singh

Rajdeep singh

526 Followers

JavaScript || Reactjs || Nextjs || Python || Rust || Biotechnology || Bioinformatic || Front-end Developer || Writer || https://officialrajdeepsingh.dev/