Skip to content

Npm command does not work Node.js >= 22 with "AllSigned" PowerShell policy when installing because npm.ps1 is not digitally signed. #60075

@pronitsateli731

Description

@pronitsateli731

Version

22.20.0

Platform

Microsoft Windows NT 10.0.26100.0 x64

Subsystem

No response

What steps will reproduce the bug?

  1. Set the PowerShell execution policy to "AllSigned", for example by Set-ExecutionPolicy AllSigned -Scope LocalMachine
  2. Install target version Node.js by administrator.
  3. Attempt to run npm command, for example npm -v.
  4. Observe that npm fails because npm.ps1 is not digitally signed.
  5. Change the PowerShell execution policy to "Remote Signed", which is not "AllSigned". Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
  6. Attempt to run npm command with the same Node.js version, for example npm -v.
  7. Observe that npm command now runs successfully.

How often does it reproduce? Is there a required condition?

Installed with "AllSigned" PowerShell policy and Node.js >= 22, this problem always reproduce.

What is the expected behavior? Why is that the expected behavior?

Node.js can run npm command with any version of Node.js, even if the PowerShell execution policy is "AllSigned".
For example this screenshot (v20)

Image

What do you see instead?

Node.js can not run npm command with Node.js >= 22 as below screenshot, if the PowerShell execution policy is "AllSigned".
The error Message is below.

npm : File C:\nvm4w\nodejs\npm.ps1 cannot be loaded. The file C:\nvm4w\nodejs\npm.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ npm -v
+ ~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
Image

Additional information

Though many people think it may be a matter of npm, but in this issue in npm, it was said that to fix this problem need to be coordinated with the Node project .
But any open issue about this problem in Node.js is not exist, so I raise this issue to Node.js side.
This bug occurs with below version. I checked those by switching Node.js version using nvm-windows.
I'm in trouble because I develop with machine with "AllSigned" PowerShell policy by Group-Policy.

Node.js Vesion npm Version included by Node.js Can run with AllSigned
v24.9.0 v11.6.0 NG
v22.20.0 v10.9.3 NG
v22.9.0 v10.8.3 NG
v22.5.1 v10.8.2 NG
v22.0.0 v10.5.1 NG
v21.7.3 v10.5.0 OK
v20.19.5 v10.8.2 OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions