DEV Community

Chirag Patel
Chirag Patel

Posted on

Fix Angular and Node Version Mismatch Using NVM on Windows

Many developers face a common issue while working with Angular projects — everything runs smoothly one day, and suddenly the next day the project refuses to start.

This usually happens due to a Node.js version mismatch.
Angular CLI and framework versions depend on specific Node versions, and if the system updates or the global Node version changes, the build commands can fail unexpectedly.

This guide explains how to manage and switch Node versions using NVM (Node Version Manager) on Windows to fix Angular version compatibility issues.


Why This Happens

Each Angular version officially supports certain Node.js versions.

For example:

Angular Version Compatible Node Version
Angular 20 Node 20
Angular 18 Node 18
Angular 17 Node 18

If the wrong Node version is active, the following errors may appear:

  • "Your Node.js version is not supported"
  • "Cannot find module @angular/cli"
  • npm install fails due to version conflicts

Step 1: Check Current Node Version

To check the current Node version, run:

node -v
Enter fullscreen mode Exit fullscreen mode

Example output:

v18.20.8
Enter fullscreen mode Exit fullscreen mode

If the project requires Node 20, switch versions using NVM.

Step 2: Check Installed Node Versions

List all installed Node versions:

nvm list
Enter fullscreen mode Exit fullscreen mode

Example:

20.19.5
20.19.0
* 18.20.8 (Currently using 64-bit executable)
Enter fullscreen mode Exit fullscreen mode

If Node 20 isn’t installed yet:

nvm install 20
Enter fullscreen mode Exit fullscreen mode

Step 3: Switch to the Required Node Version

Activate Node 20:

nvm use 20
Enter fullscreen mode Exit fullscreen mode

Confirm the active version:

node -v
Enter fullscreen mode Exit fullscreen mode

Expected output:

v20.x.x
Enter fullscreen mode Exit fullscreen mode

If the version does not change, it may indicate a global Node installation conflict.

Step 4: Fix PATH Conflicts on Windows

To identify which Node executable is being used, run:

where node
Enter fullscreen mode Exit fullscreen mode

If the result includes both paths below, there’s a PATH conflict:

C:\Program Files\nodejs\node.exe
C:\Users\<username>\AppData\Roaming\nvm\v20.19.5\node.exe
Enter fullscreen mode Exit fullscreen mode

To fix:

  • Open Control Panel → System → Advanced system settings → Environment Variables
  • Edit the **Path **variable under “System variables”
  • Remove this entry (if it exists):
C:\Program Files\nodejs\
Enter fullscreen mode Exit fullscreen mode
  • Save and restart the terminal
  • Run:
nvm use 20
node -v
Enter fullscreen mode Exit fullscreen mode

Now Node 20 should be active.

Step 5: Install the Matching Angular CLI Version

To install Angular CLI compatible with Angular 20:

npm install -g @angular/cli@20
Enter fullscreen mode Exit fullscreen mode

Inside the project folder:

npm install
Enter fullscreen mode Exit fullscreen mode

Verify:

ng version
Enter fullscreen mode Exit fullscreen mode

The CLI and framework should both show version 20.

Step 6: Run the Project

Start the Angular development server:

ng serve
Enter fullscreen mode Exit fullscreen mode

OR

npm start
Enter fullscreen mode Exit fullscreen mode

If the setup is correct, the project should compile and run without errors.


💡 Bonus Tip: Use .nvmrc for Per-Project Node Version Management

Create a .nvmrc file in the project’s root directory and add the Node version number:

20
Enter fullscreen mode Exit fullscreen mode

Then simply run:

nvm use
Enter fullscreen mode Exit fullscreen mode

This automatically switches to the correct Node version for that specific project.


🎯 Conclusion

Using NVM (Node Version Manager) simplifies working with multiple Angular projects that require different Node versions.

With this setup:

  • Node and Angular versions remain compatible
  • Version conflicts are easy to fix
  • Projects stay consistent across development environments

No more unexpected “version mismatch” errors — just smooth Angular development 🚀

Top comments (0)