Search code examples
react-nativeyarn-v2

Error: Cannot find module '/Users/user/directory/app/.yarn/releases/yarn-3.6.4.cjs'


Trying to upgrade from React Native to 0.73.6 to 0.74.2.

React Native upgrade instructions said to add the following

packageManager": "[email protected]

to package.json and add the following to a file ".yarnrc.yml" with this content. There is no directory yarn/releases/yarn-3.6.4.cjs

nodeLinker: node-modules yarnPath: .yarn/releases/yarn-3.6.4.cjs

But I now get the following error

node:internal/modules/cjs/loader:1148 throw err; ^ Error: Cannot find module '/Users/user/Dir/Dir2/.yarn/releases/yarn-3.6.4.cjs' at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) at Module._load (node:internal/modules/cjs/loader:986:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) at node:internal/main/run_main_module:28:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }

I have attempted to set yarn to berry and have performed corepack enable Node.js v20.14.0


Solution

  • Finally figured it out. In your project directory and your home directory run remove all yarn files and folders. $cd ~ && rm -rf .yarn/ && rm -f yarn.lock then run $ yarn set version 3.6.4.

    I then had issues with Watchman so I ran $ brew uninstall watchman && brew update && brew install watchman followed by $ watchman watch-del-all $ watchman shutdown-server

    Hope this saves you a few hours