VSCODE的终端无法执行npm命令
-
问题原因:PowerShell 默认可能限制脚本执行。
-
解决方法:
-
在 PowerShell 中运行以下命令,查看当前策略:
Get-ExecutionPolicy
-
如果结果是
Restricted
,改为RemoteSigned
:Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
-
按
Y
确认更改。
-
问题原因:PowerShell 默认可能限制脚本执行。
解决方法:
在 PowerShell 中运行以下命令,查看当前策略:
Get-ExecutionPolicy
如果结果是 Restricted
,改为 RemoteSigned
:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
按 Y
确认更改。