Not able to install Yarn through corepack
Asked Answered
T

5

15

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'
Tyson answered 1/11, 2022 at 16:14 Comment(1)
Could you please post the directory where corepack is installed.Oliviero
S
24

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

Savannasavannah answered 5/11, 2022 at 3:13 Comment(0)
B
11

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
Boiling answered 9/3, 2023 at 16:3 Comment(0)
O
1

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.

Oliviero answered 3/11, 2022 at 15:26 Comment(0)
M
1

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

Munda answered 23/10, 2023 at 16:22 Comment(0)
H
0

I was able to fix this for yarn version 4 by following the corepack manual installation instructions.

npm uninstall -g yarn pnpm
npm install -g corepack
corepack enable

These are the latest installation instruction for yarn.

FYI: I used asdf to install node

Hearten answered 8/8 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.