Javascript 为什么 powershell 不运行 Angular 命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58032631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why powershell does not run Angular commands?
提问by Amir Makram
I have started to learn Angular but I note that powershell in Windows gives me an error whenever I make an angular command like:
我已经开始学习 Angular,但我注意到每当我发出如下 angular 命令时,Windows 中的 powershell 都会给我一个错误:
ng new new-app
or
或者
ng serve
this is the error what I got:
这是我得到的错误:
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
P.S. I try these commands in cmd and it works.
PS我在cmd中尝试这些命令并且它有效。
回答by Amir Makram
Remove ng.ps1from the directory C:\Users\%username%\AppData\Roaming\npm\then try clearing the npm cache at C:\Users\%username%\AppData\Roaming\npm-cache\
ng.ps1从目录中删除,C:\Users\%username%\AppData\Roaming\npm\然后尝试清除 npm 缓存C:\Users\%username%\AppData\Roaming\npm-cache\
回答by Stanley Mohlala
I solved my problem by running below command
我通过运行以下命令解决了我的问题
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
回答by Hozaifa
script1.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170
无法加载 script1.ps1,因为在此系统上禁用了运行脚本。有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=135170 上的about_Execution_Policies
This error happens due to a security measure which won't let scripts be executed on your system without you having approved of it. You can do so by opening up a powershell with administrative rights (search for powershell in the main menu and select Run as administrator from the context menu) and entering:
发生此错误是由于一项安全措施,未经您批准,该措施不会让脚本在您的系统上执行。您可以通过打开具有管理权限的 powershell(在主菜单中搜索 powershell 并从上下文菜单中选择以管理员身份运行)并输入:
set-executionpolicy remotesigned
回答by Palla Vishal
open windows powershell, run as administrater and SetExecution policy as Unrestricted then it will work.
打开 windows powershell,以管理员身份运行,将 SetExecution 策略设为 Unrestricted,然后它就可以工作了。

