没有为命令yarn安装预设版本

Lub*_*jek 16 zsh asdf node.js yarn-lock.json apple-m1

我的 asdf 有问题。\n我已经安装了最新的 Nodejs。

\n
asdf install nodejs latest\n... \nasdf local nodejs latest / asdf global nodejs latest \n
Run Code Online (Sandbox Code Playgroud)\n

但如果我尝试

\n
yarn                                                        \xef\x80\x97 \nNo preset version installed for command yarn\nPlease install a version by running one of the following:\n\nasdf install nodejs 18.0.0\n\nor add one of the following versions in your config file at /Users/../project-name/.tool-versions\nnodejs 14.17.0\nnodejs 19.0.1\n
Run Code Online (Sandbox Code Playgroud)\n

但我的项目结构中的 .tool-version 已经包含它:

\n
nodejs 18.0.0\nnodejs 19.0.1\n
Run Code Online (Sandbox Code Playgroud)\n

(对于我的项目,我需要nodejs >= 18)\n我正在使用苹果M1芯片。

\n

小智 45

当您在不同版本的节点(而不是活动节点)下安装了纱线时,就会发生这种情况。由于yarn是node版本下的包,因此您需要使用新的活动版本的node来(重新)安装yarn:

npm install -g yarn
Run Code Online (Sandbox Code Playgroud)

那么它应该可以工作。

  • npm 安装成功后,还需要 `asdf reshim nodejs 16.19.1` (或您的目标版本)。然后“yarn”终于起作用了!谢谢威尔。 (2认同)