NVM (Node Version Manager) allows you to install and switch between multiple Node.js versions. Setting a Node.js default version means every time you open a new terminal session, the preferred Node latest version will be loaded.

Steps to Set Default Node Version:

List Installed Versions

nvm ls

Install Desired Node Version (if not already installed)

nvm install 22.17.1

Set It as Default

nvm alias default 22.17.1

This will set the specified version as the default. Every new terminal session will now use this version automatically.

Also Read: Node JS Test-Driven Development

Why Set a Default Version?

  • Consistency across projects
  • Avoid version conflicts
  • Simplify development and CI/CD

You can check the current version by running:

node -v

If you want to switch temporarily in a session, use:

nvm use 16

For team projects, consider using a .nvmrc file in the root directory with the preferred version. This will allow team members to sync easily by running:

nvm use

Also Read: The Engine “Node” is Incompatible with this Module

Conclusion

Set a default Node.js version using NVM to make life easier. Get the steps to lock your preferred version across terminal sessions.