'Can't find module yarn-3.1.1.cjs
I'm trying to install a package using yarn, but I keep getting 'Cannot find module' error. It gives this error when I try to run any command using yarn in this folder. Notably, the error started occuring after I deleted the .yarn folder.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/home/chronos/user/Downloads/codes/some-react-app/.yarn/releases/yarn-3.1.1.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:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Should I delete my yarn.lock file, or what can I do to solve the problem.
Solution 1:[1]
UPDATE:
It seems that the link I provided earlier has been removed. It was just the yarn-x.x.x.cjs file that was there. Another solution I found was to delete ALL the yarn configuration files. On bash terminal that'srm -f ~/.yarn*. Then run yarn install again and you should be good to go ?
Old post:
I found a fix.
For those who face this problem, what I did was, from my project directory, create a directory .yarn and inside it another directory, releases, then download: https://raw.githubusercontent.com/GlobexDesignsInc/gxdrecords.com/master/.yarn/releases/yarn-3.1.1.cjs and paste in the releases folder.
You should now be able to run yarn commands from your project directory.
Solution 2:[2]
Running rm ~/.yarnrc and rm ~/.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 ran yarn --version and got 1.22.17
Solution 3:[3]
I set my yarn version (in yarnrc.yml) to the default yarn (I used homebrew)
yarnPath: /usr/local/bin/yarn
Then, I was able to rerun
yarn set version berry
Then reset yarnPath to .yarn/releases/...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Tu?n Tr?n Qu?c |
| Solution 3 | codster |
