无法在Windows上安装纱线
我有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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只应该这样做:
corepack enable enable
// elses if node.js< 16.10(yarn 1.0):npm安装 - 全球纱
YARN的终端内部检查安装, - version
,如果您拥有NPM,它肯定可以工作(我已经在Windows和Linux上安装了很多次,并且它在官方1.0 doc 和官方2.0+ doc !You should only do that :
corepack enable
// else if Node.js <16.10 (yarn 1.0) :npm install --global yarn
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 !就我而言,我从官方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
我的同样问题,这意味着您的机器上安装了纱线,但纱线的可执行文件目录不在系统的路径中。
按照下面的步骤操作:
检查纱线安装目录:
NPM bin -g
添加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
)。重新启动终端或命令提示或git bash
验证纱线安装
纱线 - 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:
check yarn installation directory:
npm bin -g
add yarn's installation directory (generated from previous step
path/to/your/yarn/bin
) to system pathLinux/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
).Restart Terminal or Command Prompt or Git Bash
Verify yarn Installation
yarn --version
those solved my problem