我如何在Windows 10上修复运行NPM运行npm运行脚本的组策略错误

发布于 2025-02-05 12:34:26 字数 944 浏览 2 评论 0原文

当我尝试在项目中运行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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

断桥再见 2025-02-12 12:34:27

在我们的情况下,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).

但可醉心 2025-02-12 12:34:27

根据 @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.

踏月而来 2025-02-12 12:34:27

我们能够通过查看批处理文件并解码其运行的内容来克服这一点,因此在我们的情况下npm start变成了:

"start": "node node_modules\\react-scripts\\scripts\\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:

"start": "node node_modules\\react-scripts\\scripts\\start",
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文