为什么powershell不运行Angular命令?

我已经开始学习Angular,但我注意到Windows中的powershell每当我发出一个角度命令时都会给我一个错误,例如:

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

附言:我在cmd中尝试这些命令,它的工作原理。


答案 1

从目录中删除,然后尝试在ng.ps1C:\Users\%username%\AppData\Roaming\npm\C:\Users\%username%\AppData\Roaming\npm-cache\


答案 2

我通过运行以下命令解决了我的问题

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser