Last updated: Apr 5, 2024
Reading time·4 min
You can use the nvm alias default 18.16.0
command to set your default
Node.js version using NVM.
The command sets your default Node version that is used in any new shell.
First, install the version that you want to set as default.
nvm install 18.16.0
Then set the version as your default Node.js version.
nvm alias default 18.16.0 nvm use 18.16.0
18.16.0
with your preferred Node.js version.The nvm alias default
command is used to set a default Node.js version to be
used in any new shell.
If you need to check which Node.js versions are installed, use the nvm ls
command.
nvm ls
Notice that the currently active Node.js version has an arrow pointing to it.
You can also use the node -v
or node --version
command to check your current
Node.js version.
node -v node --version
If you need to list what Node.js versions are available to install, use the
nvm ls-remote
command.
nvm ls-remote
The output of the command is quite long as it shows each Node.js version that can be installed using NVM.
If you try to set a version that you haven't installed as your default, you would get an error.
# ⛔️ ! WARNING: Version '19.5.0' does not exist. # default -> 19.5.0 (-> N/A) nvm alias default 19.5.0
I don't have version 19.5.0 installed on my machine, so trying to set it as the default Node.js version raises an error.
You first have to install the version.
nvm install 19.5.0 nvm use 19.5.0
And then set it as your default Node.js version.
nvm alias default 19.5.0
If the node -v
command doesn't show the expected version, try to restart your
shell.
After you set a certain Node.js version as your default, all new shells will start with the specified version.
You can also use the nvm use default
command to switch to the default version
once it has been set.
nvm use default
If you need to set the latest Node.js version that is installed on your PC as the default using NVM, issue the following command.
nvm alias default node nvm use node
node -v
The command sets your default Node.js version to the latest Node version that is installed on your computer.
The latest Node.js version that is installed on my PC is 20.0.0
.
If you need to set your default Node.js version to the latest Node.js remote version:
nvm install node
nvm alias default node nvm use node
If you need to set the long-term supported Node.js version as the default, use the following commands.
nvm install --lts nvm use --lts
nvm alias default 'lts/*'
If the command doesn't work for you, try to wrap lts/*
in double quotes.
nvm alias default "lts/*"
If you still see the old version after setting a default Node.js version in VS Code.
Try to restart VS Code.
Try to completely close the IDE and reopen it.
Try to clear the cache in VS Code.
Try to rerun the node -v
or node --version
command in a new terminal
window.
node -v node --version
You can learn more about the related topics by checking out the following tutorials: