Member-only story
How to Use NVM to Manage Node.js 17 and NPM 8
A practical guide for NVM
This article was published for nvm
0.39.0
, node.js 17, and npm 8. All concepts in this article still work. However, you can check out the following article for updated examples:
Node.js 17 was released on October 19, 2021. It comes with npm 8 and many new features. Are you ready to try it out?
The best way to try is to use NVM (Node Version Manager) to upgrade node.js and npm versions. It can help us to mitigate the risk.
This is a similar article, and all concepts still work. However, all examples are updated 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), in particular on these platforms: unix, macOS, and windows WSL.
The latest version of nvm
is 0.39.0
, 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: