Not able to install Yarn through corepack

10.1k views Asked by At

Environment: Windows, Node 16.18.0, Corepack 0.14.1

I am following these instructions to install Yarn.

When I run corepack prepare [email protected] or corepack prepare [email protected] --activate

I get the following error:

Preparing [email protected]... Internal Error: ENOENT: no such file or directory, stat 'C:\Users\rashiditaba\AppData\Local\node\corepack\yarn\3.2.4' Error: ENOENT: no such file or directory, stat 'C:\Users\***\AppData\Local\node\corepack\yarn\3.2.4'
4

There are 4 answers

0
TTook On

I had the same issue and discovered that the yarn.js file was being downloaded, but not into the expected location.

The yarn.js file was downloaded to a new folder created with the path C:\Users\***\AppData\Local\node\corepack\corepack-NEW_RANDOM_NAME I just moved this folder into the yarn directory and renamed it to match the expected path C:\Users\***\AppData\Local\node\corepack\yarn\4.0.0

Then I reran the corepack prepare yarn@stable --activate command and now yarn is reporting that it is version 4.0.0

0
Yoandy Doble Herrera On

Hello I experienced the same problem. Corepack is an experimental tool to help with managing versions of your package managers. Due to its experimental status, Corepack currently needs to be explicitly enabled to have any effect.

Disable Corepack with the command:

corepack disable

You will now be able to install yarn via npm:

npm install -g yarn --force

To check the installed version of yarn use:

yarn -v

To upgrade the version use (stable version 3.2.4):

yarn set version stable

Now you can enable corepack again (if it fails keep it disabled):

corepack enable

Try the failed command:

corepack prepare [email protected] --activate

I leave you the link with the description of the solution: https://nodejs.org/dist/latest/docs/api/corepack.html

I hope it helps you

0
BeeFriedman On

From the error your getting it seems like you have to wrong directory PATH to yarn. Find the directory where yarn is installed and update it's PATH in the environment variables.

0
Daemotron On

I had the same issue. There seems to be a problem which prevents corepack from downloading the latest yarn.js script file.

My solution:

  • run corepack enable as described in the install guide
  • create the folder AppData\Local\node\corepack\yarn\3.4.1
  • download https://repo.yarnpkg.com/3.4.1/packages/yarnpkg-cli/bin/yarn.js and place the file in the folder you just created
  • run corepack prepare yarn@stable --activate

and you should be good to go:

> yarn -v
3.4.1