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
Install Desired Node Version (if not already installed)
Set It as Default
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:
If you want to switch temporarily in a session, use:
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:
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.