Issue
Today I decided to install yarn and I tried to install it with npm i -g
and brew install
, however whenever I run yarn -v
this error appears:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/Users/franciscomendes/.yarn/releases/yarn-berry.cjs'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
When I run the which yarn
command this is the path that appears (when I install with HomeBrew):
/usr/local/bin/yarn
When I look for .yarn using which .yarn
this appears in the terminal:
.yarn not found
If I install globally with npm and then list my global dependencies, note that I have version 1.22.11, however the error persists.
/Users/franciscomendes/.npm-global/lib
├── autocannon@7.0.5
├── clinic@8.0.1
├── expo-cli@4.5.2
├── npm-check-updates@11.4.1
├── npm@
├── serve@12.0.0
└── yarn@1.22.11
And when I run the which yarn
command, this is the path that appears:
/Users/franciscomendes/.npm-global/bin/yarn
Do you have a solution for this problem?
P.S.:By the way, node and npm work normally (as well as others).
Solution
Check if you have an .yarnrc file in your repo, if you have it, just delete it and try to run yarn
and must work
Answered By – Miguel Angel Velasco
Answer Checked By – Robin (AngularFixing Admin)