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

2.9k views Asked by At

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?

4

There are 4 answers

1
Marian Klühspies On BEST ANSWER

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/"
   ...
}
0
tonisives On

I had to use yarn 3.6.4 instead of 4.0.2 to make this error go away

yarn set version 3.6.4

1
João Paulo Ferreira On

I had a similar problem and solved it by deleting yarn.lock and running yarn command again:

 ➤ YN0000: ┌ Resolution step 
 ➤ YN0082: │ npm-run-path@npm:^5.1.0: No candidates found 
 ➤ YN0000: └ Completed in 8s 78ms 
 ➤ YN0000: · Failed with errors in 8s 102ms ```


0
Don On

I tried the other answers and they didn't work for me. I also tried everything I could think of: Reinstalling yarn, running yarn cache clear, deleting the entire ~/.yarn directory. What finally did it for me was deleting the .yarn file in the project repo. Posting in case anyone else runs into this.