This Windows error indicates that Node.js is not in your system PATH, preventing npm and node commands from running. The fix involves adding Node.js to your PATH environment variable or reinstalling Node.js.
This Windows-specific error indicates that the operating system cannot locate the Node.js executable in the system's PATH environment variable. When you run npm or node commands in Command Prompt or PowerShell, Windows searches a series of directories (defined by the PATH variable) to find the executable. If Node.js was never added to PATH, or if the installation was incomplete or corrupted, Windows reports this error because it cannot find the node.exe file. The npm command itself depends on Node.js, so if the system can't find Node, npm commands will also fail. This is particularly common on Windows because, unlike Unix-like systems, Windows doesn't automatically add application paths to the system environment during installation. You must manually configure PATH or ensure the installer does it correctly during the Node.js installation process.
Open Command Prompt (Win + R, type cmd) and check if Node.js exists on your system:
node --version
npm --versionIf both commands fail with the "not recognized" error, proceed to the next step.
You can also verify the installation by checking if the directory exists. Open File Explorer and navigate to C:\Program Files\nodejs. If this folder doesn't exist, Node.js is not installed, and you need to download and install it from https://nodejs.org.
This is the most common fix. Windows needs to know where to find the node.exe and npm.cmd files:
1. Press Win + R, type systempropertiesadvanced.exe, and press Enter
2. Click the "Environment Variables" button at the bottom
3. Under "System variables" (not User variables), find the variable named Path and click "Edit"
4. Click "New" and add: C:\Program Files\nodejs
5. If you installed Node.js in a different directory, add that path instead
6. Click OK three times to close all dialogs
7. Close all open Command Prompt and PowerShell windows completely
8. Open a new Command Prompt window and test: node --version
The key is closing and reopening your terminal so it reads the updated PATH.
If the previous step didn't work, you may have conflicting PATH entries. Open Environment Variables again and check both "User variables" and "System variables" sections:
1. Look for any entries containing npm, nodejs, or node in either section
2. In the User variables PATH, check if you have: C:\Users\{YourUsername}\AppData\Roaming\npm
3. In the System variables PATH, check if you have: C:\Program Files\nodejs
Important: Both should exist, but they should reference different locations. If you see duplicates or outdated paths (like C:\nodejs or old version directories), remove them.
Correct configuration:
- System PATH: C:\Program Files\nodejs
- User PATH: C:\Users\{YourUsername}\AppData\Roaming\npm (for global npm packages)
If the above steps don't work, your Node.js installation is likely corrupted. Completely remove and reinstall:
1. Press Win + R, type appwiz.cpl, and press Enter to open Programs and Features
2. Find "Node.js" in the list, click it, and select "Uninstall"
3. Delete the leftover directory: Navigate to C:\Program Files\nodejs and delete it if it still exists
4. Clear npm cache folder: Navigate to C:\Users\{YourUsername}\AppData\Roaming, find the npm and npm-cache folders, and delete them
5. Restart your computer
6. Download the LTS version from https://nodejs.org/
7. Run the installer and ensure "Add to PATH" is checked (it should be by default)
8. Complete the installation
9. Open a new Command Prompt and verify: node --version && npm --version
If the error appears only in VS Code's terminal but works in standalone Command Prompt, VS Code's terminal hasn't recognized the PATH update:
1. Close Visual Studio Code completely
2. Open a Command Prompt and verify Node.js works: node --version
3. Reopen VS Code
4. Click the terminal area and click the trash/close icon to kill the current terminal
5. Open a new terminal in VS Code (Ctrl + `)
If it still doesn't work, configure VS Code to use a specific shell. Go to VS Code settings, search for terminal.external.windowsExec, and ensure it points to a valid terminal application.
If you're using nvm-windows to manage Node versions, the issue may be with how nvm is configured:
# Check if a Node version is active
nvm list
# If no version is active, install and use one
nvm install lts
nvm use lts
# Verify
node --version && npm --versionIf you still have issues, uninstall nvm-windows itself, reinstall it, and then install a fresh Node.js version through nvm.
PATH Resolution Order: Windows searches PATH entries from left to right, stopping at the first match. If you have multiple Node.js installations (old version, nvm, or manual install), PATH order matters. Use where node in Command Prompt to see which node.exe is actually being used.
System vs User PATH: User-level PATH variables take precedence over system-level ones in Windows. This means if you add Node.js to System PATH but it's already (incorrectly) in User PATH, the wrong path will be used. Always check both and remove duplicates or outdated entries.
npm Global Packages: The C:\Users\{username}\AppData\Roaming\npm directory is where globally installed npm packages are stored. This path should also be in your PATH if you want to run global command-line tools directly, but it's separate from the main Node.js PATH.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error