Last updated: Apr 4, 2024
Reading timeยท2 min
Use the nvm install-latest-npm
command to change the version of npm using
nvm
.
The command updates your npm version to the latest supported npm version by the current Node.js version.
nvm install-latest-npm # ๐๏ธ same as above nvm install --latest-npm
nvm install-latest-npm
updates your npm version to the latest supported npm version by the current Node.js version.You can use the npm -v
command to check your version of npm.
# ๐๏ธ check the version of npm npm -v # ๐๏ธ check version of Node.js node -v
npm
If you want to install a specific version of npm
, you have to use the
npm install
command with a version modifier.
npm install -g npm@7.7.2 npm install -g npm@8.11.0
You can use the npm view npm versions
command to list all versions of npm
.
npm view npm versions
If you want to show the latest npm
version, use the npm view npm version
command.
npm view npm version
Alternatively, you can update npm
to the latest version with the following
command.
npm install -g npm@latest
sudo
(macOS and Linux) or open CMD as an administrator (Windows) if you get a permissions error.If you want to install the latest version of Node.js, use the nvm install node
command.
# ๐๏ธ for macOS and Linux nvm install node # ๐๏ธ for Windows nvm install latest
node
is an alias for the latest version.
If you want to use this version, issue the nvm use node
command or the command
from the end of your installation message.
# ๐๏ธ for macOS and Linux nvm use node # ๐๏ธ for Windows nvm use latest
If you want to install the long-term supported version or another version, first
use the nvm ls-remote
or nvm list available
command.
# ๐๏ธ for macOS and Linux nvm ls-remote # ๐๏ธ for Windows nvm list available
Currently the long-term supported version is 18.12.1
, so I can install the
specific version with the following command.
# ๐๏ธ install specific version nvm install 18.12.1
To use the specific version, issue the nvm use
command.
# ๐๏ธ use specific version nvm use 18.12.1
You can use the nvm ls
command to check which nvm
versions you have
installed and which is the currently active version.
nvm ls node --version npm --version
nvm
command, you have to prefix the command with sudo
(macOS and Linux) or start PowerShell or CMD as an administrator (Windows) and rerun the command.You can view all of the available nvm
commands in
this section of the package's GitHub
repository.