
这个错误是因为 PowerShell 的执行策略(Execution Policy)阻止了
.ps1脚本的运行。你当前系统禁止运行脚本,导致npm.ps1无法加载。
✅ 方法 1:临时允许当前会话运行脚本(只会影响当前 PowerShell 窗口,关闭后就失效,不会降低系统整体安全性)
bash
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
✅ 方法 2:全局更改执行策略(⚠️如果你确实需要长期使用 PowerShell 运行脚本,可以运行,但这会降低系统安全性)
bash
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
注:本人前端小白 ,如有不对的地方还请多多指教