Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac Os error: Error: Cannot find module '/Users/xxx/.yarn/releases/yarn-1.22.1.js' #8399

Closed
bgits opened this issue Oct 20, 2020 · 6 comments

Comments

@bgits
Copy link

bgits commented Oct 20, 2020

Running MacOs Catalina 10.15.7.

After receiving warnings about yarn being out of date I tried to upgrade it. I have tried several means and yarn no longer works on the machine.

After initially using yarn upgrade

I tried using the curl script: curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc

The install terminates with:

internal/modules/cjs/loader.js:834
  throw err;
  ^

Error: Cannot find module '/Users/xxx/.yarn/releases/yarn-1.22.1.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
> Yarn was installed, but doesn't seem to be working :(.

which yarn returns /Users/xxx/.yarn/bin/yarn

Wondering how to get past this and yarn working again?

@barbalex
Copy link

I have the exact same problem. Frustrating to see that due to no solution I will have to - what exactly? Buy a new pc?

@barbalex
Copy link

barbalex commented Dec 25, 2020

I found a .yarnrc file (can't remember the exact name). Deleted it. And now everything works!!!!!

Got the idea because yarn worked in other folders. So If you encounter this: look for a .yarn file in the folder, remove it and hope for the best.

@paul-soporan
Copy link
Member

Yep, Yarn will look for .yarnrc and .yarnrc.yml files and read the yarnPath field to spawn the specified binary. If the binary doesn't exist, it crashes. These files with a yarnPath are created when running yarn set version / yarn policies set-version, which are for per-project installs, so don't run it in your home directory. If you accidentaly do, just delete the generated .yarnrc / .yarnrc.yml file.

@kevinadhiguna
Copy link

Much appreciated @paul-soporan !

Reason

I once upgraded Yarn using yarn set version latest and did not realize that it produces .yarnrc in my home directory.

Solution

  1. Removing .yarnrc (it existed in home directory in mycase. Make sure you are in the directory where .yarnrc remains) :
rm .yarnrc
  1. I loaded profile config (e.g. : .bashrc, .zshrc, etc.) with :
source ~/.zshrc

Finally yarn -v worked again.

@AwolDes
Copy link

AwolDes commented Dec 30, 2021

@paul-soporan

so don't run it in your home directory.

You have made my day with this solve 😄 was going nuts trying to understand why .yarn/releases/yarn-1.22.1.cjs --version was giving me 3.1.0. Sure enough, I had yarn configs in my home dir.

@azs-dev
Copy link

azs-dev commented Oct 21, 2023

Much appreciated @paul-soporan !

Reason

I once upgraded Yarn using yarn set version latest and did not realize that it produces .yarnrc in my home directory.

Solution

  1. Removing .yarnrc (it existed in home directory in mycase. Make sure you are in the directory where .yarnrc remains) :
rm .yarnrc
  1. I loaded profile config (e.g. : .bashrc, .zshrc, etc.) with :
source ~/.zshrc

Finally yarn -v worked again.

If

rm .yarnrc

does not work. make sure to also do

rm .yarnrc.yml

😃👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants