berry: [Bug?]: Missing install step in docs?

Self-service

  • I’d be willing to implement a fix

Describe the bug

I’m trying to install yarn on my new Mac. I am running Node.js 17.5, so the docs (https://yarnpkg.com/getting-started/install) say the only thing I need to do is corepack enable. But yarn install still says zsh: command not found: yarn. I feel like there is another step that is supposed to be in the docs in order to install the yarn command. Or maybe there is a problem with my environment?

To reproduce

corepack enable
yarn install

Environment

macOS 12.2.1, asdf 0.9.0, asdf-nodejs master 50656e5

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Actually, according to this comment I just found, the solution to this seems to be to run asdf reshim nodejs after enabling corepack.

asdf install nodejs latest
asdf global nodejs latest
corepack enable
asdf reshim nodejs

btw the trick is to simply restart the shell after corepack enable - and there’s no reason not to add that to the instructions.

Something like “restart/reload your shell to pick up the yarn path”

Yes, there is a step missing from the documentation. After corepack enable, you need to run corepack prepare yarn@[version] --activate to actually install Yarn.

The steps from @zach-betz-hln kind of worked for me, but I had to choose a specific version so the install for me was:

corepack prepare yarn@3.3.0 --activate

And it worked after refreshing my terminal (I restarted after each corepack command just to be safe).

@popmonkey - Thank you. This was my issue as well.

For future readers, here’s what I did:

  1. I already had Node.js version 18.12.1
  2. I followed the Yarn install steps at https://yarnpkg.com/getting-started/install by running corepack prepare yarn@stable --activate which output Preparing yarn@stable for immediate activation...
  3. I’m on macOS 13.0.1 (22A400), which defaults to the zsh shell, so I sourced ~/.zshrc in my Terminal, but still got the zsh: command not found: yarn message
  4. I restarted my Terminal, then yarn -v output 3.3.0 👍

this should not be closed. i’m on a fresh OS X (12.5) with node 16.14.2 and are running into the exact same issue following the instructions @ https://yarnpkg.com/getting-started/install

i’ve never had yarn 1 installed on this machine. i’ve never even heard of asdf

Closing as this isn’t a Yarn issue, asdf doesn’t seem to support Corepack.

i’m just following install instructions on the yarn home page. the bug seems to be with the instructions, not some tool i never used.

+1 to add the command raised by @gonfalon - this solved my issue & was nowhere to be seen in the docs.

EDIT:

Surprisingly, I still cannot get the latest version of yarn to work in my environment - here are the commands I run:

$ node --version
v16.14.2
$ yarn --version
1.18.0
$ corepack enable
$ corepack prepare yarn@3.2.0 --activate
Preparing yarn@3.2.0 for immediate activation...
$ node --version
v16.14.2
$ yarn --version
1.18.0

Running macOS 12.3.1

Just to add information here, if you still get Yarn v1 instead of v3, even after all the above, experiment doing a yarn set version berry. You can also replace the berry with a specific version, like yarn set version 3.4.1.