我已经开始学习 Angular,但我注意到 Windows 中的 powershell 每当我执行如下 angular 命令时都会出现错误:
ng new new-app
或者
ng serve
这是我得到的错误:
ng : File C:\Users\< username >\AppData\Roaming\npm\ng.ps1 cannot be loaded because
running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ ng serve
+ ~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS 我在 cmd 中尝试了这些命令,它可以工作。
原文由 Amir Makram 发布,翻译遵循 CC BY-SA 4.0 许可协议
从目录
C:\Users\%username%\AppData\Roaming\npm\
中删除ng.ps1
,然后尝试清除C:\Users\%username%\AppData\Roaming\npm-cache\