powershell执行yo命令 提示 npm\yo.ps1,因为在此系统上禁止运行脚本。

执行yo命令 报错:

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

如图
20200415040728.png

打开微软的官方文档
https://docs.microsoft.com/zh...

使用命令

Get-ExecutionPolicy -List

检查powershell设置,看结果是否是:

Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine       AllSigned

CurrentUser 如果不是 RemoteSigned 就使用命令(管理员模式

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

设置CurrentUser为RemoteSigned 就可以了。

你可能感兴趣的:(powershell,yo,yoeman)