Member-only story
How To Use NVM To Manage Node.js 19 and NPM 9
A practical guide for NVM
This article was published for nvm
0.39.2
, node.js 19, and npm 9. All concepts in this article still work. However, you can check out the following article for updated examples:
Node.js 19 was released on October 18, 2022. It comes with npm 9 and many new features. Are you ready to try it out?
NVM (Node Version Manager) is the best way to upgrade node.js and npm versions. It can help us to mitigate the risk.
This is a rewrite with new versions of nvm
, node.js, and npm.
Install NVM
nvm
manages node.js and npm versions. It is designed to be installed per user and invoked per shell. nvm
works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), particularly on Unix, macOS, and windows WSL.
The latest version of nvm
is 0.39.2
, and it can be installed by curl or wget
command:
The script, install.sh
, clones the nvm repository to ~/.nvm
, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile
, ~/.zshrc
, ~/.profile
, or ~/.bashrc
).
In the profile file, such as ~/.zshrc
, we see the above lines are added.
Use NVM
After nvm is installed, we can use the following command to install the latest version of node.js: