I'm upgrading my React Native project to a newer version. What I’ve done for this:
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:
Search on the internet, found simailar issue but not related to mine. https://github.com/puppeteer/puppeteer/issues/10509
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.
"devDependencies": {
"@react-native/babel-preset": "^0.76.1",
}
Reference: carloscuesta/react-native-error-boundary#897.
I managed to fix this issue by replacing presets: ['module:metro-react-native-babel-preset'], with presets: ['module:@react-native/babel-preset'], in both babel.config.js & .babelrc
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