I have problem with asdf. I have already install nodejs latest.
asdf install nodejs latest
...
asdf local nodejs latest / asdf global nodejs latest
But if I try
yarn
No preset version installed for command yarn
Please install a version by running one of the following:
asdf install nodejs 18.0.0
or add one of the following versions in your config file at /Users/../project-name/.tool-versions
nodejs 14.17.0
nodejs 19.0.1
But my .tool-version in project structure already contains it:
nodejs 18.0.0
nodejs 19.0.1
(For my project I need nodejs >= 18) I am using apple M1 chip.
This happens when you have yarn installed under a different version of node, but not the active one. As yarn is a package under the node version, so you need to (re)install yarn with the new active version of node:
npm install -g yarn
Then it should work.
There is a better way to solve "No preset version installed for command yarn" issue without installing yarn
globally. There will be problems with yarn global installation if you need different yarn versions in different projects on the same machine.
Make sure you have set the required version of node js in asdf local to the project/folder:
asdf local nodejs <requried version>
e.g.
asdf local nodejs 18.19.1
or you can specify node js for all projects on your machine
asdf global nodejs <requried version>
Then you will enable yarn. It is shipped with node js starting from version 16.9. You can enable it with command:
corepack enable
then you most likely will need to reshim asdf binaries:
asdf reshim
If you using node js older than 16.9 use npm to install yarn globally as @wil-w suggested
In case if you upgraded or downgraded node js version in you package and getting that "No preset version installed for command yarn" error then you can apply the same solution above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With