Open1

asdfでNodeをインストールした際にyarnが使えないときの解決メモ

yamadashyyamadashy

asdf でNode.jsをインストールして、 .tool-versions でバージョンを指定し、

$ asdf install nodejs 20.13.1

yarn を叩くと以下のように、yarnがinstallされてないので asdf install nodejsしろと言われる。

No preset version installed for command yarn
Please install a version by running one of the following:

asdf install nodejs 20.13.1

or add one of the following versions in your config file at /Users/yamadashy/ghq/github.com/yamadashy/tech-blog-rss-feed/.tool-versions
nodejs 18.19.0
nodejs 18.19.1
nodejs 18.20.2
nodejs 20.10.0
nodejs 20.11.0
nodejs 20.11.1
nodejs 20.12.2

以下で解決

$ corepack enable
$ asdf reshim nodejs

npm でインストールしてもいいが、今はcorepackを使うのが良い。

参考
https://shikiyura.com/2022/08/install_nodejs_using_asdf/
https://github.com/asdf-vm/asdf-nodejs/issues/332