Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Yarn fail with "no candidates found" errors?

For example, I'm trying to upgrade netlify-cli from 17.7.0 to 17.8.1 using yarn upgrade-interactive and the following error happens:

➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @netlify/zip-it-and-ship-it@npm:9.28.1: No candidates found
➤ YN0000: └ Completed in 1s 602ms
➤ YN0000: · Failed with errors in 1s 617ms

and

➤ YN0000: · Yarn 4.0.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ @formkit/vue@npm:^1.3.0: No candidates found
➤ YN0000: └ Completed in 22s 953ms
➤ YN0000: · Failed with errors in 22s 972ms

According to npmjs.com the package @netlify/zip-it-and-ship-it is available in the version requested:

enter image description here

I recently had this error multiple times with different packages.

What exactly does this error tell me and why does this happen?

like image 235
Marian Klühspies Avatar asked Sep 10 '25 18:09

Marian Klühspies


1 Answers

As somebody pointed out on GitHub:

Yarn caches the version history of the remote registry locally and relies on it, instead of looking into the remote registry again when a version is not found locally.

This is most likely a bug and can currently be solved by deleting the Yarn Berry Metadata Cache for NPM, which is located here on Windows

C:\Users<your-user>\AppData\Local\Yarn\Berry\metadata\

or here

~/.yarn/berry/metadata/npm

Edit: You can also add a preinstall hook your package.json to clean the registry cache before every yarn install run

"scripts": {
   "preinstall": "rm -r ~/AppData/Local/Yarn/Berry/metadata/npm/"
   ...
}
like image 191
Marian Klühspies Avatar answered Sep 13 '25 12:09

Marian Klühspies