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.
rm -f ~/.yarn*. Run yarn set version stable or your specific version, then run yarn install again and you should be good to go 😊
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With