Fix npm.ps1 cannot be loaded in PowerShell: npm.cmd and execution policy checks

| Application program | 1k+ Reads

If PowerShell blocks npm.ps1, first check which npm installation it finds, then try the trusted npm.cmd wrapper. This lets you run npm without changing PowerShell's execution policy. Check the exact error before changing any policy settings.

Quick fix: check the path, then use npm.cmd

The error may look like this:

npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system.

In that case, PowerShell selected npm's PowerShell script wrapper and blocked it. Check the available commands and their locations:

Get-Command npm -All | Select-Object CommandType, Name, Source
Get-Command npm.cmd -CommandType Application -All | Select-Object Name, Source

If the results point to your expected Node.js installation, test the command-line wrapper before retrying your project command:

npm.cmd --version
npm.cmd install

If several installations appear, use the full path you verified. For example, this is a common installation location, not a path guaranteed on every computer:

& 'C:\Program Files\nodejs\npm.cmd' install

Adding .cmd selects that wrapper instead of npm.ps1; it does not change execution policy. Microsoft documents using a command's extension or full path to distinguish commands in about_Command_Precedence.

Read the effective policy in the terminal that fails

$PSVersionTable.PSVersion
Get-ExecutionPolicy
Get-ExecutionPolicy -List

The first policy command shows the effective setting; -List shows the contributing scopes. Their precedence, from highest to lowest, is:

MachinePolicy → UserPolicy → Process → CurrentUser → LocalMachine

A configured higher-priority scope wins; Undefined means that scope has no setting. PowerShell does not simply choose the most restrictive value in the list. See Microsoft's execution-policy documentation.

MachinePolicy and UserPolicy come from Group Policy. A Process or CurrentUser setting cannot override them. Also check the actual host: Windows PowerShell (powershell.exe) and PowerShell 7 (pwsh.exe) are managed separately, so a result from one does not establish the other's effective setting.

Disabled scripts and unsigned scripts are different errors

Error or conditionWhat to check
“running scripts is disabled”Check for an effective Restricted policy, which allows individual commands but blocks PowerShell script files.
“is not digitally signed”Check the policy and the file's signature. AllSigned requires signed scripts, including local ones.
Unsigned file under RemoteSignedAn Internet-marked script can require a trusted signature even though other local scripts run.

The signature-related error can include:

File C:\Program Files\nodejs\npm.ps1 cannot be loaded.
The file C:\Program Files\nodejs\npm.ps1 is not digitally signed.

For a verified file path, these commands inspect its signature and any Internet-zone marker without changing the file:

Get-AuthenticodeSignature -FilePath 'C:\Program Files\nodejs\npm.ps1'
Get-Item -LiteralPath 'C:\Program Files\nodejs\npm.ps1' -Stream Zone.Identifier -ErrorAction SilentlyContinue

No output from the second command does not prove that a file is trustworthy. Under RemoteSigned, a targeted Unblock-File may be appropriate after reviewing a downloaded script and its origin. It removes the download marker, not the signature requirement imposed by AllSigned. Microsoft's Set-ExecutionPolicy examples explain this distinction.

When a session-only policy change is appropriate

If running PowerShell scripts is approved for your environment and you actually need the .ps1 wrapper, you can consider a session-only setting:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
Get-ExecutionPolicy

This can allow an unsigned local script, but still requires checking downloaded scripts and any higher-priority Group Policy. The setting lasts for the current process and its child sessions; closing the session removes it.

Bypass disables the policy's script checks and prompts. Giving it Process scope limits its lifetime, not which scripts you trust. It is unnecessary when calling npm.cmd is sufficient.

CurrentUser and LocalMachine changes persist. Do not omit -Scope by accident: Set-ExecutionPolicy defaults to LocalMachine. These scope behaviors and the separate PowerShell hosts are described in the Microsoft cmdlet reference.

If npm.cmd is not found or installation still fails

Check Get-Command node -All and your intended Node.js installation or version-manager selection. If the installation is missing, use the official Node.js and npm setup instructions. Changing PowerShell policy will not create a missing npm.cmd.

If npm.cmd --version works but npm.cmd install reports a different npm error, investigate that new message separately. Package, registry, or project errors are not automatically execution-policy errors.

Verification scope

Checked on Windows on 2026-10-17 with Windows PowerShell 5.1, PowerShell 7.6.5, Node.js 22.17.0 and npm 11.5.2. In isolated child sessions, after loading the diagnostic cmdlets, npm.ps1 was blocked under Restricted and AllSigned. In both hosts and both cases, npm.cmd --version returned 11.5.2 while the session's policy stayed unchanged. No project packages were installed and no persistent execution-policy settings were changed.

This article was last edited at