【发布时间】:2022-11-24 02:27:29
【问题描述】:
我克隆了一个使用 Yarn 1.x 的项目并试图运行它,但我找不到获得正确版本的 Yarn 的方法。我想我一定错过了什么。
评论终端会话:
# using node16.18.0
$ nvm use v16
Now using node v16.18.0 (npm v8.19.2)
# start with no yarn installed
$ yarn --version
zsh: command not found: yarn
# package.json has packageManager set for Yarn v1.22.19
$ cat package.json | grep packageManager
"packageManager": "yarn@1.22.19"
# enable corepack, and it ignores the packageManager version
$ corepack enable
$ yarn --version
3.2.4
# manually ask corepack to use v1.22.19, but it again ignores this
$ corepack prepare yarn@1.22.19 --activate
Preparing yarn@1.22.19 for immediate activation...
$ yarn --version
3.2.4
# manually ask corepack to run yarn 1.22.19, but it again ignores it
$ corepack yarn@1.22.19 --version
3.2.4
所以使用 Corepack 我似乎无法说服它使用 Yarn 版本。
此外,使用npm install -g 安装似乎也无法正常工作。
# disable corepack so there's no yarn installed
$ corepack disable
$ yarn --version
zsh: command not found: yarn
# install yarn v1.22.19
$ npm install -g yarn@1.22.19
added 1 package, and audited 2 packages in 326ms
found 0 vulnerabilities
# somehow it's installed 3.2.4 again
$ yarn --version
3.2.4
【问题讨论】:
-
which yarn返回什么? -
@mrienstra 对我来说它返回全局纱线(.nvm/versions/node/...)