What does nvm change when you switch projects?
nvm selects Node.js, which runs JavaScript outside the browser. It is installed for a user and works in the shell where it is loaded. A new shell or an automated build can use a different Node.js version unless its setup selects the same one.
A package manager such as npm or Yarn installs the project’s dependencies. Switching Node.js can also change the bundled npm version your shell runs. Your project’s declared package-manager version and lockfile stay as written. Check the active Node.js and npm versions on both machines before you compare their builds.
Which nvm can you use on your computer?
The nvm-sh project is for compatible shells such as bash and zsh on macOS, Unix-like systems and Windows Subsystem for Linux. Native Windows has a separate project called nvm-windows. Its installer and setup instructions are different.
Use the nvm-sh release and installation instructions for your shell. Before installing an old Node.js version, check your operating system and processor. Official Apple silicon binaries began with Node.js 16.0.0. On platforms without a matching binary, nvm may attempt to build from source, which needs a compiler.
How can you check what version a project expects?
Read a fictional README and .nvmrc on paper. Do not install or switch Node.js versions for the exercise.
- Compare the two cluesWrite that the README says Node.js 22 and that .nvmrc says 22.14.0. Record which exact version nvm looks for when asked to switch using that file. A switch needs the version to be installed already.
- Check a different shellWrite that the local shell already uses 22.14.0 but the build machine says 20. Compare the two settings before blaming the package manager.
- Keep the decisions separateWrite down the chosen Node.js version and the package-manager version. Note which configuration the project and automated build should agree on.
What should you keep with the project?
Keep its .nvmrc and setup instructions with the code. The documented nvm commands can read .nvmrc when no version is supplied. An exact release stays specific. An alias such as the latest long-term support release can point to a different version over time.
Have the build select or install the intended version explicitly. Review a change to the runtime pin and the package-manager lockfile separately. The nvm tool is open source. The build service or machine that runs your project can have its own cost.