learnbydoing
learnbydoing

Reputation: 509

Installation Problem: Cannot find module Yarn

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
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── npm@
├── [email protected]
└── [email protected]

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).

Upvotes: 19

Views: 24980

Answers (3)

Carlos Roberto
Carlos Roberto

Reputation: 1

ll -a ~
rm -fdr .yarnrc.yml
curl -o ~/.yarn/releases/yarn-1.22.19.cjs \ https://repo.yarnpkg.com/1.22.19/packages/yarnpkg-cli/bin/yarn.js`

Upvotes: -1

Miguel Angel Velasco
Miguel Angel Velasco

Reputation: 676

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

Upvotes: 66

Albiona Hoti
Albiona Hoti

Reputation: 33

Do which yarn and if the path includes a .yarn, go to that path, delete everything with .yarn and .yarnrc.yml.

Upvotes: 0

Related Questions