React native/hermes构建错误.没有这样的文件或目录:index.android.bundle.pack



描述

在hermesEnabled设置为true的情况下,在构建过程中获取以下消息("…"表示删除的文本(:

(完整的错误日志在这里(

androidappbuildgeneratedassetsreactreleaseindex.android.bundle:13:134: warning: the variable "Promise" was not declared in function "isBoldTextEnabled"
...
androidappbuildgeneratedassetsreactreleaseindex.android.bundle:27:2907: warning: the variable "DebuggerInternal" was not declared in function "value 14#"
...
androidappbuildgeneratedassetsreactreleaseindex.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 'androidappbuildintermediatessourcemapsreactreleaseindex.android.bundle.packager.map'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at Object.<anonymous> (C:esites-grocerytest2.hermesplumpclientnode_modulesreact-nativescriptscompose-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_modulesreact-nativereact.gradle' line: 191
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'cmd'' finished with non-zero exit value 1

(引用的文件存在,至少在生成失败后存在(。

环境

  • 在Windows 10上构建
  • React Native版本:0.62.2

我试着做什么

  • 如https://github.com/facebook/react-native/issues/25927#issuecomment-539415154

在build.gradle中修改以下额外的包定义:

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

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

修复了错误(警告仍然存在(
APK已创建并正在运行。。

./gradlew clean

做完之后/gradlew clean对我有效。

对于Windows:

gralde clean

最新更新