Platform
Ubuntu 20.04.01
Node v14.13.0
NPM 6.14.8
Command(s)
yarn
, yarn --version
or any yarn
-related terminal command
What is the current behavior?
After installing yarn via the official installation tutorial on Ubuntu this error occurs:
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '/home/tafadzwa/.yarn/releases/yarn-berry.cjs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:747:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Running which yarn
yields /usr/bin/yarn
What is the expected behavior?
yarn
or yarn --version
should output a version string
Steps to reproduce
Install yarn on the platform under Platform heading and type yarn --version
Any other information
Similar to #7948
Running
rm ~/.yarnrc
andrm ~/.yarnrc.yml
and worked for me. Don’t worry if either file isn’t there.~/.yarnrc
was not found in my case so I ended up deleting~/.yarnrc.yml
only. I logged out and in to the terminal and ranyarn --version
and got1.22.5
Why does this solution work
When I ran
npm install -g yarn
ornpm install -g yarn@berry
yarnrc
and/oryarnrc.yml
were/was created with theyarnPath
pointing to/home/[username]/.yarn/releases/yarn-berry.cjs
. Runningyarn --version
would run a lookup foryarn-berry.cjs
based on theyarnPath
Sinceyarn-berry.cjs
wasn’t there the runtime would trigger an appropriate error hence it makes sense that removingyarnrc
and/oryarnrc.yml
solves the issue.