node.jszshapple-m1asdfyarn-lock.json

No preset version installed for command yarn


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.


Solution

  • 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.