I have not seen this issue posted yet, so I'm assuming there may be something wrong with my set up. I completed the steps to upgrade from react-native 0.59.5 to 0.60.4, but I encounter this error when I run the command 'react-native run-android'
/node_modules/@react-native-community/cli/build/commands/server/middleware/getDevToolsMiddleware.js:86
__esModule", {
^^^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
The file getDevToolsMiddleware.js, in /node_modules/@react-native-community/cli, differs from what is seen in GitHub.
Does anyone know what the problem is and know how to overcome this obstacle?
I don't have this issue with react-native 0.59.5.
Does it happen on a newly initiated project? What about re-installing your node_modules?
Can you send me the output of this command as well: yarn list --pattern @react-native-community/cli?
yarn list --pattern @react-native-community/cli
yarn list v1.16.0
├─ @react-native-community/[email protected]
├─ @react-native-community/[email protected]
├─ @react-native-community/[email protected]
└─ @react-native-community/[email protected]
✨ Done in 1.42s.
This is an existing project where we are attempting to upgrade react-native 0.59.5 to 0.60.4. I've tried several times reinstalling the node_modules.
Please run npx react-native init TestProject and see what's there. I'd like to rule out an issue with your environment. Or some babel/Metro cache (please make sure to clear it with yarn start --reset-cache)
No problems creating and running TestProject.
I tried to run the following commands on my project, but still encountered the same error executing the last command.
watchman watch-del-all
rm -rf $TMPDIR/react-native-packager-cache-*
rm -rf $TMPDIR/metro-bundler-cache-*
rm -rf node_modules/
yarn cache clean
yarn install
yarn start --reset-cache
Likely something cache related. I'd advise running cd $TMPDIR and removing everything that has "metro" and "haste" inside a name.
I think I have uncovered the issue. Under scripts in the package.json, I have "postinstall": "rndebugger-open". I removed the line and reinstalled node_modules. When I ran "yarn start --reset-cache", there was no error and the Metro was running.
It appears that the when postinstall is run the ./node_modules/react-native/local-cli/server/middleware/getDevToolsMiddleware.js code is replaced. That's probably why I'm seeing a difference in the files mentioned earlier.
I have no idea what "rndebugger-open" does, but I don't think we can protect from that, sorry. Closing, as it's not actionable. Thanks for coming back with the resolution :)
Upgrading react-native-debugger-open to version 0.3.22, from 0.3.19, when using react-native version 0.60 helped me.
Most helpful comment
Upgrading react-native-debugger-open to version 0.3.22, from 0.3.19, when using react-native version 0.60 helped me.