Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 447
Luboš Hájek Avatar asked Sep 01 '25 18:09

Luboš Hájek


2 Answers

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.

like image 142
Wil W Avatar answered Sep 04 '25 08:09

Wil W


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.

like image 37
Dmitry Shvetsov Avatar answered Sep 04 '25 08:09

Dmitry Shvetsov