在 Office 插件生成器 Yeoman 中运行“yo office”时出现执行策略错误

Mah*_*had 3 powershell office-addins yeoman angular project-web-addins

我想使用 yeoman 为带有 Angular 的办公室创建一个插件。在power shell中安装了nodeJs、Angular、yeoman、generator-office等需求工具后,我尝试运行此代码

yo office 
Run Code Online (Sandbox Code Playgroud)

但我收到了这个错误:

 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  
Run Code Online (Sandbox Code Playgroud)

Mah*_*had 5

在我阅读此链接中的此错误后,我发现我应该更改“currentUser”的执行策略。

  1. 运行此代码以在 PowerShell 中查看系统的执行策略。
Get-ExecutionPolicy -List
Run Code Online (Sandbox Code Playgroud)
  1. 如果您的 CurrentUser ExecutionPolicy 是“未定义”,您应该使用此代码将其更改为“RemoteSigned”
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Run Code Online (Sandbox Code Playgroud)

我已经在 windows 10 pro x64、Yeoman 4.3.0、NodeJs 14.17.0、NPM 6.14.13 中进行了测试