【发布时间】:2020-01-21 18:20:26
【问题描述】:
我已经开始学习 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
附:我在 cmd 中尝试了这些命令,它可以工作。
【问题讨论】:
-
你能运行
Get-ExecutionPolicy并提供输出吗?另外你可以跑到C:\Users\< username >\AppData\Roaming\npm并打开ng.ps1的属性,看看是否有一个勾选框显示“已阻止”,如果有,请取消勾选。 -
我认为最好的方法是删除 ng.ps1 当我做了一切都再次工作
-
@TheFabio 实际上可能我永远不会知道,在删除 ng.ps1 后一切都进行得很完美。
-
我的执行政策不是问题,而是我如何发送论点。如果你在同一条船上,请查看Executing Angular Serve From Powershell With Parameters Fail
-
为什么会被标记为重复?它绝对不是重复的。虽然报错信息一样,但解决方法完全不同
标签: javascript angular powershell angular-cli