React-native/hermes build error. no such file or directory: index.android.bundle.packager.map

2k views Asked by At

Description

Getting the following messages during build with hermesEnabled set to true

('...' represent removed text):

(full error log is here)

android\app\build\generated\assets\react\release\index.android.bundle:13:134: warning: the variable "Promise" was not declared in function "isBoldTextEnabled"
...
android\app\build\generated\assets\react\release\index.android.bundle:27:2907: warning: the variable "DebuggerInternal" was not declared in function "value 14#"
...
android\app\build\generated\assets\react\release\index.android.bundle:92:57773: warning: the variable "setTimeout" was not declared in function "wi"
...

fs.js:114
    throw err;
    ^
Error: ENOENT: no such file or directory, open 'android\app\build\intermediates\sourcemaps\react\release\index.android.bundle.packager.map'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at Object.<anonymous> (C:\esites-grocery\test2.hermes\plumpclient\node_modules\react-native\scripts\compose-source-maps.js:33:43)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)

FAILURE: Build failed with an exception.

* Where:
Script 'node_modules\react-native\react.gradle' line: 191

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'cmd'' finished with non-zero exit value 1

(The referenced file exists, at least after the build failed).

Environment

  • Building on Windows 10
  • React Native version: 0.62.2

What I tried to do

2

There are 2 answers

1
Yossi On

Modifying the following extra packages definition in build.gradle:

extraPackagerArgs: ["--sourcemap-output", "$buildDir/intermediates/assets/release/index.android.bundle.map"]

to

extraPackagerArgs: ["--sourcemap-output", "$buildDir/intermediates/sourcemaps/react/release/index.android.bundle.packager.map"]

Fixed the error (the warnings are still there).
An APK is created and is running..

0
Talha Yousaf On

./gradlew clean

After doing the ./gradlew clean It worked for me.

OR

For Windows:

gralde clean