【问题标题】:Yarn commands can't be executed in the regular way纱线命令不能以常规方式执行
【发布时间】:2022-01-02 06:39:46
【问题描述】:

当一个纱线命令被执行时,它会给出一个安全错误作为未经授权的访问。

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

但可以使用如下所示的命令绕过它。

powershell -ExecutionPolicy Bypass -File '%FILEPATH%\yarn.ps1' yarn start

所有 npm 命令都工作正常,错误仅在执行 yarn 命令时发生。这些命令在 Windows 10 操作系统上运行。
有没有办法以常规方式执行纱线命令? (只执行命令 yarn start

【问题讨论】:

    标签: javascript windows yarnpkg


    【解决方案1】:

    这似乎是 PowerShell 中的一个错误

    您的系统上安装了节点吗?

    尝试卸载 yarn

    并尝试使用installer 安装它

    这将为您提供一个 .msi 文件,运行时将引导您完成在 Windows 上安装 Yarn。

    如果您使用安装程序,您首先需要安装 Node.js。

    如果不起作用,您可以使用此链接中描述的命令 link

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

    also this link could help you

    【讨论】:

    • 我已经安装了 Node 并按照上面的方法进行了尝试。但是还是会出现同样的错误
    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    • @NuvinduNirmana 这似乎是一个PowerShell的错误。我认为这些链接可以帮助您:1- github.com/yarnpkg/yarn/issues/6913 2- nextofwindows.com/…
    • 成功了!!我在第二个 link 中使用了该命令。 Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted。 @DariushStony 添加您的评论作为答案,以便可以接受。
    • @NuvinduNirmana Tnx 完成。现在你可以接受我的答案作为正确答案了
    猜你喜欢
    • 1970-01-01
    • 2017-03-12
    • 2022-01-19
    • 1970-01-01
    • 2018-08-06
    • 2018-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多