我如何在Windows 10上修复运行NPM运行npm运行脚本的组策略错误
当我尝试在项目中运行NPM脚本时,我会收到以下组策略错误:
PS C:\Users\reir8p\code\whiteboard\frontend> npm run start
> [email protected] start
> ng serve
This program is blocked by group policy. For more information, contact your system administrator.
如果直接执行命令,则不会收到任何错误。
PS C:\Users\reir8p\code\whiteboard\frontend> ng serve
\ Generating browser application bundles... {works as expected}
我的软件包的相关行是:
{
"name": "whiteboard",
"version": "0.0.0",
"scripts": {
"start": "ng serve",
},
...
我能够成功执行> NPM从“ Windows PowerShell”作为管理员运行
。我无法在Windows安全策略中找到任何相关部分。
我也与其他NPM脚本遇到了相同的错误。尝试安装Anaconda时,我还收到了类似的“此程序被阻止...”错误,我认为这可能是相关的。
是否有人收到类似的错误或知道我应该在哪里进行故障排除?谢谢。
I'm receiving the following group policy error when I try to run NPM scripts in my project:
PS C:\Users\reir8p\code\whiteboard\frontend> npm run start
> [email protected] start
> ng serve
This program is blocked by group policy. For more information, contact your system administrator.
If I execute the command directly, I do not receive any errors.
PS C:\Users\reir8p\code\whiteboard\frontend> ng serve
\ Generating browser application bundles... {works as expected}
The relevant lines of my package.json file is:
{
"name": "whiteboard",
"version": "0.0.0",
"scripts": {
"start": "ng serve",
},
...
I am able to successfully execute > npm run start
from "Windows PowerShell" as an administrator. I haven't been able to find any relevant sections in my Windows security policies.
I get the same error with other NPM scripts as well. I also received a similar "This program is blocked..." error when trying to install Anaconda, which I think might be related.
Has anyone else received a similar error or know where I should look to troubleshoot? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我们的情况下,Applocker阻止了执行。
请检查Windows EventLog(事件查看器/应用程序和服务日志/Microsoft/Windows/Applocker/MSI和脚本)。
In our case Applocker blocked the execution.
Please check the Windows Eventlog (Event viewer/Applications and Services Logs/Microsoft/Windows/AppLocker/MSI and Scripts).
根据 @Suede1997的建议,通过更新Appleocker安全策略来修复此问题。本地安全策略/应用程序控制策略/pallocker/脚本规则 - >删除对“所有人”的限制(设置了我的限制,以允许“程序文件文件夹中的所有文件”,并允许“位于Windows文件夹中的所有文件”。
事件查看器有助于确定何时阻止脚本。
As per @Suede1997's recommendation, Fixed this by updating the AppLocker security policies. Local Security Policy/Application Control Policies/AppLocker/Script Rules --> Remove restriction for "Everyone" (mine was set to allow "All Files located in the Program Files folder" and allow "All files located in the Windows folder".
Event Viewer was helpful to identify when the scripts were being blocked.
我们能够通过查看批处理文件并解码其运行的内容来克服这一点,因此在我们的情况下
npm start
变成了:We were able to overcome this by looking at batch file and decoding what it would have run, so in our case
npm start
became: