如何修复错误-无法加载nodemon.ps1,因为此系统上已禁用运行脚本

2025-06-04

如何修复错误-无法加载nodemon.ps1,因为此系统上已禁用运行脚本

Windows 系统本地机器运行 nodemon 出错的解决方案:

nodemon.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.
Enter fullscreen mode Exit fullscreen mode

因此,如果您遇到此错误,只需按照以下步骤解决问题即可-

步骤1:

使用以管理员身份运行打开 Windows PowerShell。

第 2 步:

正如您所见,错误是关于“执行策略”的,首先要查看当前执行策略中的内容。在 Windows PowerShell 中使用此命令来获取它

Get-ExecutionPolicy
Enter fullscreen mode Exit fullscreen mode

这里你会看到“受限”。所以,主要原因是——在这个系统上运行脚本是“受限”的。

步骤3:

现在我们需要修改此策略以允许该操作。使用以下命令将其设置为“不受限制”:

Set-ExecutionPolicy Unrestricted
Enter fullscreen mode Exit fullscreen mode

这里会弹出提示信息,按 Y 键即可更改

就是这样。为了确保万无一失,您可以再次使用此命令检查执行策略状态

Get-ExecutionPolicy
Enter fullscreen mode Exit fullscreen mode

您将获得输出“Unrestricted”

问题已解决。现在您可以在机器上使用 nodemon 了。

文章来源:https://dev.to/digitacoder/how-to-fix-error-nodemon-ps1-cannot-be-loaded-because-running-scripts-is-disabled-on-this-system-34fe
PREV
通过“开发者优先”学习缩小 Kubernetes 技能差距
NEXT
Personalyzer:使用 Wix Studio 轻松定制滑板