close

DEV Community

Tony Stark
Tony Stark

Posted on

Fix npm is not recognized in PowerShell on Windows

If PowerShell shows this after you installed Node.js:

npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program.
Enter fullscreen mode Exit fullscreen mode

do not start by reinstalling your project.

This is usually a Runtime / PATH problem. Until Windows can find npm, later errors from Electron, node-gyp, better-sqlite3, or a voice coding app are just noise.

Here is the order I would use.

1. Open a fresh PowerShell window

If Node.js was installed while PowerShell or VS Code was already open, the old terminal may not see the updated PATH.

Close PowerShell. If you are using VS Code, close and reopen VS Code too.

Then run:

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

If both work, you do not need to repair anything else at this layer.

2. Check command resolution the PowerShell way

Use Get-Command first:

Get-Command node -ErrorAction SilentlyContinue
Get-Command npm -ErrorAction SilentlyContinue
Get-Command npm.cmd -ErrorAction SilentlyContinue
Enter fullscreen mode Exit fullscreen mode

Then use where.exe, not bare where:

where.exe node
where.exe npm
Enter fullscreen mode Exit fullscreen mode

In PowerShell, where can be interpreted as an alias for Where-Object. where.exe asks Windows directly where the executable is.

3. If node works but npm does not

Try:

npm.cmd -v
Get-Command npm.cmd -ErrorAction SilentlyContinue
Enter fullscreen mode Exit fullscreen mode

If npm.cmd works but npm does not, the Node install may be present but command resolution or PATH order is wrong.

Common expected locations look like:

C:\Program Files\nodejs\node.exe
C:\Program Files\nodejs\npm.cmd
Enter fullscreen mode Exit fullscreen mode

Do not paste random PATH edits yet. First confirm whether those files exist:

Test-Path "C:\Program Files\nodejs\node.exe"
Test-Path "C:\Program Files\nodejs\npm.cmd"
Enter fullscreen mode Exit fullscreen mode

4. Check PATH only after the files exist

$env:Path -split ';' | Select-String -SimpleMatch 'nodejs'
Enter fullscreen mode Exit fullscreen mode

If C:\Program Files\nodejs is missing from PATH, repair the Node.js installation or add the path through Windows Environment Variables.

After changing PATH, open a new PowerShell window and retest:

node -v
npm -v
where.exe node
where.exe npm
Enter fullscreen mode Exit fullscreen mode

5. Only then run project commands

When Runtime is fixed, go back to the project folder:

cd C:\path\to\your\project
Test-Path .\package.json
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

If package.json is missing, you are in the wrong folder.

If Electron or native modules fail after this, that is a different layer.

Free diagnostic

I maintain a read-only Windows diagnostic for this exact class of setup failure:

Run the free Windows AI coding setup diagnostic

It checks:

  • Runtime: Node.js, npm, PATH
  • Project folder and package.json
  • Electron install state
  • Native modules such as better-sqlite3
  • Visual Studio Build Tools detection
  • Voice coding stack indicators

GitHub repo:

WiaiKit Windows AI Coding Setup Repair

The script is read-only. It does not install, delete, or modify files.

Recovery order

For npm is not recognized in PowerShell, use this order:

  1. Open a fresh PowerShell or VS Code terminal.
  2. Run node -v and npm -v.
  3. Run Get-Command node, Get-Command npm, and Get-Command npm.cmd.
  4. Run where.exe node and where.exe npm.
  5. Confirm C:\Program Files\nodejs\npm.cmd exists.
  6. Repair Node.js PATH if needed.
  7. Only then run npm install inside the project.

Related free page:

Fix npm is not recognized in PowerShell on Windows

The paid WiaiKit repair kit is the longer recovery path after the diagnostic tells you which layer is broken: npm PATH, Electron, node-gyp, Visual Studio Build Tools, native modules, OpenWhispr, Codex, Claude Code, and push-to-talk voice workflows.

Top comments (0)