skip to Main Content

I’m upgrading my React Native project to a newer version. What I’ve done for this:

  1. Created a new React Native project using the latest version.
  2. 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.
  3. 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


  1. If you updated your react native project, check your @react-native/etc

    Config file:
    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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search