Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command not found: corepack when installing Yarn on Node v17.0.1

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.

like image 558
Stud Sterkel Avatar asked Mar 01 '23 09:03

Stud Sterkel


2 Answers

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.

like image 185
Ayelegun Kayode Avatar answered Mar 03 '23 23:03

Ayelegun Kayode


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 [email protected] --activate before reshim

like image 43
mihaa123 Avatar answered Mar 03 '23 22:03

mihaa123