47

I'm following the Yarn installation instructions on Yarn's website (https://yarnpkg.com/getting-started/install). Those instructions say that on Node version 16.10.0 and higher you can install Yarn by enabling corepack with the following command:

corepack enable

However, running that command returns:

zsh: command not found: corepack

I installed Node via Homebrew and node -v returns v17.0.1. I'm on an M1 Mac running Big Sur.

Stud Sterkel
  • 883
  • 1
  • 8
  • 17
  • 2
    I would suggest use the LTS version of nod: `node:16.13.0`. Node 17 will never be LTS: https://nodejs.org/en/about/releases/ – Robert-Jan Kuyper Nov 23 '21 at 14:15
  • 2
    I'm facing a similar issue - installed node (16.13.1) with asdf. Was able to run corepack enable - but getting "zsh: command not found: yarn" – mihaa123 Dec 04 '21 at 10:40
  • Corepack will not work in Node.js snap. https://github.com/nodejs/snap/issues/26 – igor Feb 28 '23 at 12:32

3 Answers3

48

Because I had installed node via nvm (and I had installed nvm using Homebrew), the corepack command wasn't available. The fix that worked for me was to install corepack via homebrew by running:

brew install corepack

After installing corepack via homebrew, I was able to run the corepack enable command from the terminal and the yarn command became available as well.

Ayelegun Kayode
  • 489
  • 3
  • 3
39

Was facing a similar issue with node installed using asdf. Also using zsh and zsh asdf plugin.

Node version: 16.13.1 Ran corepack enable - and got zsh: command not found: yarn

What solved for me: asdf reshim nodejs

Also try to run corepack prepare yarn@3.1.1 --activate before reshim

mihaa123
  • 1,012
  • 9
  • 19
7

I solved it like this:

From the https://github.com/nodejs/corepack docs

npm uninstall -g yarn pnpm
npm install -g corepack

Use with 'sudo' if you're using OSX

alp_the_developer
  • 615
  • 1
  • 9
  • 23