question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Metro suddenly started to fail in React Native Application

See original GitHub issue

Description

‘bundleRelease’ fails for Android right after the bundler starts, in the step described bellow. I have tried to run this same process at older branches of my project that worked fine before, but even there the builds are now failing.

The same errors happens when running:

npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

> Task :app:bundleProdReleaseJsAndAssets
warning: the transform cache was reset.
                 Welcome to React Native!
                Learn once, write anywhere

error src/app.js: function (prevType) {
Error: function (prevType) {
  this.state.exprAllowed = false;

  this.state.exprAllowed = false;
  if (prevType === types._let || prevType === types._c...<omitted>...

} could not be cloned. Run CLI with --verbose flag for more details.
  if (prevType === types._let || prevType === types._c...<omitted>...
} could not be cloned.
    at Object.serialize (node:v8:260:7)
    at _default (/.../node_modules/metro/node_modules/@babel/core/lib/transformation/util/clone-deep.js:16:30)
    at normalizeFile (/.../node_modules/metro/node_modules/@babel/core/lib/transformation/normalize-file.js:52:36)
    at normalizeFile.next (<anonymous>)
    at run (/.../node_modules/metro/node_modules/@babel/core/lib/transformation/index.js:31:50)
    at run.next (<anonymous>)
    at /.../node_modules/metro/node_modules/@babel/core/lib/transform-ast.js:20:41
    at Generator.next (<anonymous>)
    at evaluateSync (/.../node_modules/gensync/index.js:251:28)

> Task :app:bundleProdReleaseJsAndAssets FAILED

System version and other requirements:

"metro-react-native-babel-preset": "0.59.0",

System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 1.21 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.11.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.6.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 29.0.2, 30.0.3
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. cd android && ./gradlew bundleRelease

Expected Results

The ‘bundleRelease’ works and generate the aab file.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
FelixMo42commented, Nov 12, 2021

This started happening because the cloneInputAst setting for babel is now set to true by default In metro.

1reaction
drop-georgecommented, Sep 28, 2021

What was the root cause of this @fansilva1991? Also running into something similar with an #<WeakSet> could not be cloned error message on React Native 0.65.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactNative Metro Bundler not starting automatically
Run react-native run-android --port 8084 in second Command Prompt window. After error screen appear clicking Android Ctrl + M , iOS Command +...
Read more >
Troubleshooting - React Native
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here, ......
Read more >
metro (the local dev server) is run from the wrong ... - You.com
If you have this error Invariant Violation: “app” has not been registered you have to replace the 'X' by 'app' . For android...
Read more >
Addressing common errors in React Native - LogRocket Blog
Another error that developers commonly encounter when attempting to run their React Native application is shown below: Unable to load script.
Read more >
Troubleshooting | React Navigation
Stale cache of Metro bundler​ ... If the module points to a local file (i.e. the name of the module starts with ./...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found