错误,而试图安装纱线在vscode当我之前一直使用npm

  • 本文关键字:npm vscode 安装 错误 reactjs
  • 更新时间 :
  • 英文 :


错误信息

yarn : File C:UsersAdminAppDataRoamingnpmyarn.ps1 cannot be loaded 
because running scripts is disabled on this system. For more 
information, see about_Execution_Policies at 
http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ yarn
+ ~~~~
+ CategoryInfo          : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

对于那些不知道如何使用Windows PowerShell解决此错误的人

  1. 打开PowerShell(以管理员身份运行)
  2. 使用该命令检查当前执行策略
Get-ExecutionPolicy
# You should get 'Restricted'
  1. 运行此命令使其为"无限制"
Set-ExecutionPolicy Unrestricted
  1. 再次检查该命令是否改变了执行策略

    Get-ExecutionPolicy
    You should get 'Unrestricted'
    
  2. 现在尝试在你的项目上运行nodemon

nodemon 'filename.js'

希望对大家有帮助