如何在Visual Studio代码上运行yarn cammand?

问题描述 投票:0回答:4

Yarn 已成功安装在我的笔记本电脑上。但每次我尝试在 VS code 中运行yarn命令时,它都会说,

'yarn' is not recognized as an internal or external command, operable program or batch file.

windows visual-studio-code yarnpkg yarn-workspaces
4个回答
15
投票

如果yarn不工作但npm在你的vs代码终端中运行正常。然后去搜索window并搜索window powercell并使用以管理员身份运行来运行它并在数字2和3中编写代码并选择yes

  1. 打开Powershell并以管理员身份运行
  2. 获取执行策略
  3. Set-ExecutionPolicy Unrestrict(如果您想要本地用户)-Scope CurrentUser
  4. 重新启动系统

10
投票

我也有类似的错误。我刚刚安装了

npm
yarn
。当我使用 VS Code 打开项目并尝试运行
yarn install
时,终端显示文件“blabla\user\AppData\Roaming pm\yarn.ps1”没有进行数字签名。当我尝试运行
yarn --version
时,也发生了同样的情况,它在 Git Bash 终端中运行良好。为了解决这个问题,我刚刚删除了上面提到的文件yarn.ps1,一切正常.


1
投票

如果您想在 Visual Studio 代码中安装 YARN,则只需使用以下步骤或使用官方 YARN 文档即可。

https://www.npmjs.com/package/vscode-yarn

您将重定向到安装yarn的官方方式。

第 1 步 - 您的系统中已安装 VS Code,如果没有,请前往 VS Code 下载页面并下载适合您操作系统的版本。

第 2 步 - 打开 VS Code 终端并运行此命令 - ext install gamunu.vscode-yarn

从 GitHub 存储库下载最新的 .vsix 版本文件并从命令行安装

code --install-extension vscode-yarn-..*.vsix 或者从 VS Code 中启动“快速打开”并运行“从 VSIX 安装...”命令。


1
投票
  1. 以管理员身份打开 PowerShell。

  2. 通过运行以下命令安装 Yarn:

npm install --全局纱线

  1. 通过以下方式验证 Yarn 安装:

纱线--版本

© www.soinside.com 2019 - 2024. All rights reserved.