react-native: Unhandled JS Exception: Unexpected token Expected a ')' or a ' after a parameter declaration.

Description

after delete file yarn.lock and yarn install then build app , that error occur error

Version

0.60.6

Output of npx react-native info

info Fetching system and libraries information… System: OS: macOS 11.6 CPU: (6) x64 Intel® Core™ i5-8500B CPU @ 3.00GHz Memory: 218.86 MB / 20.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.3.0 - /usr/local/bin/node Yarn: 1.22.17 - ~/Documents/RabilooWorkSpace/yakuodo_app_mobile/node_modules/.bin/yarn npm: 7.15.1 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.6 => 0.60.6

Steps to reproduce

step 1: delete file yarn.lock and Podfile.lock step 2: run ‘yarn install’ step 3: run ‘cd ios and Pod install’ step 4: build app after show splash screen , app show error

error

Snack, code example, screenshot, or link to a repository

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 30 (2 by maintainers)

Most upvoted comments

It’s an error in react-native class -> node_modules/react-native/Libraries/Blob/URL.js

For some reason inside the class they are having to type as variables in a .js file If you remove everything like typing, it works again.

Example: To alter append(key: string, value: string) -> append(key, value)

I finally got it to work by setting explicit versions in my devDependencies and resolutions. I also needed to delete my node_modules and yarn.lock, but YMMV. I went back to 7.16.5 since it was the upgrade to 7.16.7 that I first saw the issue, but the latter may be safe.

"devDependencies": {
    "@babel/core": "7.16.5",
    "@babel/preset-flow": "7.16.5",
    "@babel/runtime": "7.16.5"
}
"resolutions": {
    "@babel/traverse": "7.16.5"
}

Facing the same error in react-native 0.61.5.

can anyone help?

It’s an error in react-native class -> node_modules/react-native/Libraries/Blob/URL.js

For some reason inside the class they are having to type as variables in a .js file If you remove everything like typing, it works again.

Example: To alter append(key: string, value: string) -> append(key, value)

Thank you so much, it fixed this error

Drop-in replacement metro-react-native-babel-preset, and running npx react-native start --reset-cache work for me.

babel/babel#14139 (comment)

it works for me.

Thanks

This appears related to babel, not react-native. I believe the issue is “@babel/traverse” 7.16.8: https://github.com/babel/babel/issues/14139

I can confirm after bumping metro-react-native-babel-preset to 0.59.0 and running npx react-native start --reset-cache everything works again

I’m working on project with RN 0.61.5 too. Monday, I finished my task and did git commit at end of the day. Yesterday, I added a dependency into package.json and did npm install, then got this error. I tried git checkout to restore everything back to monday, delete lock file, node_modules, ~/npm. Nothing could help resolve the error. I got same error on other (unmodified) projects using RN 0.61.5. Lost 2 days and my work is still same as monday 😦

change your babel.config.js file

presets: [[
    'module:metro-react-native-babel-preset',
    {
      unstable_disableES6Transforms: true
    }
]],

It’s an error in react-native class -> node_modules/react-native/Libraries/Blob/URL.js

For some reason inside the class they are having to type as variables in a .js file If you remove everything like typing, it works again.

Example: To alter append(key: string, value: string) -> append(key, value)

For 0.63.x at least, that file hasn’t changed in almost 2 years so it shouldn’t suddenly be breaking now. There must be another dependency that has changed recently that is causing this error.

If the solution in the Babel repository doen’t work for someone, we will need a repository that we can use to reproduce the bug.

same error with RN: 0.62.2 “@babel/core”: “7.16.5”, “@babel/runtime”: “7.16.5”, “@babel/traverse”: “7.16.5”, “@babel/preset-flow”: “7.16.5”, “babel-jest”: “24.9.0”, “metro-react-native-babel-preset”: “0.59.0”

I have uninstalled node_modules, cleaned Gradle build, re-installed everything and started the app. but still, it is showing the same error.

try yarn start --reset-cache to start app,maybe the error build cache is exist.

now, i found solution to fix this issue . my solution : “devDependencies”: { “@babel/core”: “7.16.5”, “@babel/preset-flow”: “7.16.5”, “@babel/runtime”: “7.16.5”, “@babel/traverse”: “7.16.5” }

FWIW, the issue doesn’t appear to be happening in RN 0.66.x