2

PowerShell 禁止运行 node.js 脚本如何解决?

 3 years ago
source link: https://www.ixiqin.com/2021/08/how-to-solve-the-powershell-prohibit-operation-node-js-script/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PowerShell 禁止运行 node.js 脚本如何解决?

对于一些比较流程化的工作,我希望将其自动化,因此我写了一个脚本,帮助我来完成这个基本的工作。

但在写完后,发现了一个问题:

helper: 无法加载文件 C:\Users\bestony\AppData\Roaming\npm\helper.ps1,因为在此系统上禁止运行脚本。有关详
细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ helper
+ ~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

这个问题倒是不复杂,是因为 PowerShell 相比于 CMD 拥有更全面的权限控制。如果想要解决的话,有两种方式:

1.换用 CMD

在目前的 Windows 中,依然是 CMD & PowerShell 双轨制,你可以直接使用 CMD 来执行你的命令,就无需关注这个权限的问题了。

2. 关闭权限

如果你需要继续使用 PowerShell,就要关闭 PowerShell 的校验,使用管理员模式打开 PowerShell,并执行如下命令,来关闭 PowerShell 的校验即可。

set-ExecutionPolicy RemoteSigned
发布日期:2021年8月28日
d9b147a3b7e8d89bf4a5ddd0518bca30?s=85&d=monsterid&r=g

作者:白 宦成

Generalist, contact me at [email protected]

查看白 宦成的所有文章。

发表评论 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

评论

显示名称 *

电子邮箱地址 *

网站地址


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK