Installing Node on a new Linux machine can be a frustrating experience, especially when you need a specific version or need to switch between different versions for different projects. The process of switching between versions can be a hassle and a nightmare. But there's good news! NVM (Node Version Manager) is a lifesaver for this problem. NVM makes it easy to install and switch between different versions of Node.js with just a few simple commands. Say goodbye to frustration and hello to easy Node version management with NVM on Linux.
Run Any one of these command
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
These commands will clone the nvm repository to a ~/.nvm directory on your device, and attempts to add the source lines from the snippet below to the correct profile file ~/.bash_profile
or ~/.zshrc
~/.profile
or ~/.bashrc
If it's failed to register then you need to manually input this snippet at the end the /.bashrc
or /.zshrc
if you use zsh
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
Now restart the terminal or run source ~/.bashrc
To verify if nvm is succesfully installed or not run nvm -v
In conclusion, NVM (Node Version Manager) makes managing Node.js versions on your Windows, Linux, or Mac device a breeze. With NVM, you can easily install, uninstall, and switch between different Node versions. To install the latest version of Node, simply run
nvm install latest
To install a specific version such as X.Y.Z, use the command
nvm install 16.18.1
You can also set a specific version as the default by running
nvm alias default vX.Y.Z
When you need to use a specific version on a project, simply run
nvm use vA.B.C
NVM is a valuable tool for managing multiple Node.js versions across different projects that require different versions.
Learn More about commands here https://github.com/nvm-sh/nvm#usage
Top comments (3)
In my 4 years of node development, nvm is the worst of the worst.
Try out volta volta.sh/, you'll never look back after that
pnpm is node package manager and also version manager.
dev.to/rennycat/pnpm-can-manage-no...
n is also a neat version manager for Node.