【发布时间】:2021-12-04 00:45:07
【问题描述】:
我想使用 yeoman 为带有 angular 的办公室创建一个插件。安装需求工具后,如 nodeJs, angular, yeoman, generator-office in power shell,我尝试运行这段代码
yo office
但是我收到了这个错误:
yo : File C:\Users\ME\AppData\Roaming\npm\yo.ps1 cannot be loaded.
The file C:\Users\ME\AppData\Roaming\npm\yo.ps1 is not digitally signed.
You cannot run this script on the current system.
For more information about running scripts and setting execution policy,
see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ yo office
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
【问题讨论】:
-
以下是基于default配置的一般信息;您的有效执行政策似乎是
AllSigned;有关详细信息,请参阅链接的副本或this answer。 -
在 Windows 工作站上,PowerShell 脚本执行默认被禁用。使用
Set-ExecutionPolicy.-Scope启用它接受 3 个范围之一;更具体的优先级更高:LocalMachine(需要管理员权限)、CurrentUser或Process(仅限当前进程)。 PowerShell CLI 也接受特定于进程的-ExecutionPolicy <policy>。执行策略也可以通过 GPO 设置,在这种情况下,它们不能通过Set-ExecutionPolicy或 CLI 更改或覆盖。
标签: angular powershell yeoman office-addins project-web-addins