Published in Node.js
2 minutes read

Setting the Default Node Version using NVM

Setting the Default Node Version using NVM

NVM (Node Version Manager) is a popular tool that allows you to manage multiple Node.js versions on your system. By default, when you install NVM, it does not set a default Node.js version for your system.

Checking Installed Node.js Versions

Before setting the default version, let's first check the Node.js versions installed on your system using NVM. Open your terminal or command prompt and type:

nvm ls

This command will display a list of installed Node.js versions, with an arrow (->) indicating the currently active version.

Setting the Default Node.js Version

To set a default Node.js version, you can use the nvm alias command. Replace VERSION_NUMBER with the desired version number, e.g., 14.17.3.

nvm alias default VERSION_NUMBER

For example, if you want to set Node.js version 14.17.3 as the default, you would run:

nvm alias default 14.17.3

Now, Node.js version 14.17.3 will be the default version used whenever you open a new terminal or command prompt window.

Verifying the Default Node.js Version

To verify that the default Node.js version is set correctly, you can use the following command:

nvm current

This command will display the currently active Node.js version, which should match the version you set as the default.

0 Comment