I’m upgrading my React Native project to a newer version. What I’ve done for this:
- Created a new React Native project using the latest version.
- Installed all the required packages that were in the old project to test for compatibility. None of the packages caused crashes in the new project.
- Imported my actual project code into the new folder.
When I try to run the project, I get the error in the node_modules
folder:
ERROR SyntaxError: [ROOT_FOLDER]/node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:
Unexpected token, expected "]" (39:5)
37 |
38 | type Registry<TEventToArgsMap: {...}> = {
> 39 | [K in keyof TEventToArgsMap]: Set<Registration<TEventToArgsMap[K]>>,
| ^
40 | };
41 |
42 | /**
Steps Tried:
- Cleaned the project cache
- Reinstall the all packages
- Build android project via Android Studio
Search on the internet, found simailar issue but not related to mine.
https://github.com/puppeteer/puppeteer/issues/10509
2
Answers
If you updated your react native project, check your @react-native/etc
Config file:
and see it’s the same as the one up top, there’s an update at react native 0.76.4 which fixes that issue
Source: https://github.com/facebook/react-native/issues/46355
Edit: Found this because was searching for the same error myself, this fixed it for me
In my case, the issue was with @react-native/babel-preset, which was not added inside the devDependencies. I added it to the devDependencies with version 0.76.1, and it worked for me.
Reference: carloscuesta/react-native-error-boundary#897.