Resolving Node Version Switching Issues with nvm: A Step‑by‑Step Guide
This article walks through diagnosing why nvm use does not change the global Node.js version, explains how multiple Node installations can conflict, and provides a clear step‑by‑step solution—including installing nvm, checking versions, installing and switching targets, and removing stray Node binaries.
Earlier I noticed an intern couldn't start a project because the Node.js version was too low, so I suggested using nvm to manage Node versions. While the nvm command reported a successful switch, the global Node version remained unchanged, leading to a deeper investigation.
1️⃣ Install nvm
where nvmIf the nvm path is not found, this command helps locate the default installation directory.
2️⃣ Check the current Node version
The system shows node V16.14.2 as the active version.
3️⃣ Install the target Node version with nvm
Use nvm install <version> to download the required version. After installation, the nvm directory contains folders for each installed Node version.
nvm list4️⃣ Switch to the target version
nvm useRunning nvm use should select the desired version, but in my case the Node version displayed by node -v stayed at 16.14.2.
5️⃣ Identify the problem
Two separate Node installations existed: the global Node path (pointed to by the system's environment variables) and the Node binary inside nvm's folder. The node -v command was still referencing the global installation, so any nvm switch had no effect.
6️⃣ Solution
Locate the global Node directory with where node and delete it. After removing the stray Node folder, the system points to the nvm‑managed Node binary.
where nodeVerify that the path now resolves to the nvm directory, then run nvm use again to confirm the version change.
PS
Instead of manually replacing node_modules , you can try the volta tool for seamless Node version switching without manual file replacement.
Rare Earth Juejin Tech Community
Juejin, a tech community that helps developers grow.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.