无法在Windows上安装纱线

发布于 2025-02-13 02:32:52 字数 398 浏览 0 评论 0原文

我有Windows 10:

$ node -v
v16.14.0
$ npm -v
8.3.1

我在终端运行,

$ npm install yarn -g

changed 1 package, and audited 2 packages in 666ms

found 0 vulnerabilities

但没有安装纱线,

$ yarn
C:\Users\G023911\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

我找不到任何有用的东西,可以说明为什么它对我不起作用。

I have Windows 10:

$ node -v
v16.14.0
$ npm -v
8.3.1

I run in terminal

$ npm install yarn -g

changed 1 package, and audited 2 packages in 666ms

found 0 vulnerabilities

but Yarn is not installed

$ yarn
C:\Users\G023911\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

I can't find anything helpful that shows why it is not working for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丿*梦醉红颜 2025-02-20 02:32:52

您只应该这样做:

  1. 如果Node.js> = 16.10(Yarn> = 2.0):corepack enable enable // elses if node.js< 16.10(yarn 1.0):npm安装 - 全球纱
  2. 请重新启动终端和编辑器(所有Windows)
  3. 如果使用YARN的终端内部检查安装, - version,如果您拥有NPM,它肯定可以工作(我已经在Windows和Linux上安装了很多次,并且它在官方1.0 doc 官方2.0+ doc

You should only do that :

  1. If Node.js >=16.10 (yarn >= 2.0) : corepack enable // else if Node.js <16.10 (yarn 1.0) : npm install --global yarn
  2. Restart your terminal and your editor (all windows) if you using the terminal inside
  3. Check installation with yarn --version but if you have npm it will works for sure (I have installed it many times on Windows and Linux this way & it's on the official 1.0 doc and official 2.0+ doc !
春风十里 2025-02-20 02:32:52

就我而言,我从官方github存储库中的下载文件中安装了纱线

noreferrer”> https://github.com/yarnpkg/yarn/releases/download/v1.22.4/yarn-1.22.4.msi (检查 。启动新标签还不够,我必须关闭它们并打开新标签。

在旧开放时启动新的,这是行不通的。关闭当前代码编辑器和终端,启动新的编辑器,检查纱线 - version

In my case I installed yarn from the download file in the official github repo
https://github.com/yarnpkg/yarn/releases/download/v1.22.4/yarn-1.22.4.msi (check for a newer version)

Then I had to CLOSE code editor and terminal. Starting new tab wasn't enough, I had to close them and open new ones.

Starting new ones while the old are open didn't work. Close the current code editor and terminal, start new ones, check yarn --version

墨小墨 2025-02-20 02:32:52

我的同样问题,这意味着您的机器上安装了纱线,但纱线的可执行文件目录不在系统的路径中。

按照下面的步骤操作:

  1. 检查纱线安装目录:
    NPM bin -g

  2. 添加YARN的安装目录(从上一步生成path/to/your/your/your/your/your/your/your/your/your/bin)到系统路径

  • linux/macOS:
    添加
    导出路径=“ path:/path/to/yarn/bin”
    〜/.bashrc〜/.zshhrc〜/.bash_profile

  • Windows:
    控制面板&gt;系统&GT;高级系统设置&gt;环境变量
    编辑路径变量可包括目录(path/to/your/your/your/your/your/bin)。

  1. 重新启动终端或命令提示或git bash

  2. 验证纱线安装
    纱线 - Version

那些解决了我的问题的人

same issue with mine, that means yarn is installed on your machine but yarn's executable directory is not in system's PATH.

follow steps below:

  1. check yarn installation directory:
    npm bin -g

  2. add yarn's installation directory (generated from previous step path/to/your/yarn/bin) to system path

  • Linux/MacOS:
    Add
    export PATH="PATH:/path/to/yarn/bin"
    to ~/.bashrc or ~/.zshhrc or ~/.bash_profile

  • Windows:
    Control Panel > System > Advanced system settings > Environment variables
    Edit PATH variable to include the directory (path/to/your/yarn/bin).

  1. Restart Terminal or Command Prompt or Git Bash

  2. Verify yarn Installation
    yarn --version

those solved my problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文