RN v0.61.4升级v0.63.4后Android Release构建报SyntaxError错误
React Native 0.61.4升级至0.63.4后Release构建报错
尝试将React Native项目从v0.61.4版本升级至v0.63.4版本,Android Debug构建可正常运行,但Release构建在执行Gradle任务:app:bundleReleaseJsAndAssets时抛出以下错误:
(node:77926) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use `node --trace-warnings ...` to show where the warning was created) /Users/me/Documents/GitHub/MyProject/android/react-native/node_modules/react-native/index.js:13 import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at wrapSafe (internal/modules/cjs/loader.js:1117:16) at Module._compile (internal/modules/cjs/loader.js:1165:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10) at Module.load (internal/modules/cjs/loader.js:1050:32) at Function.Module._load (internal/modules/cjs/loader.js:938:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47
项目结构特殊:React Native根目录位于Android根目录内部,已在app/build.gradle中做了必要的适配修改。即使创建结构类似的全新项目,仍会遇到该问题。
复现步骤:
cd react-native npm i npx react-native run-android --variant=release
内容的提问来源于stack exchange,提问作者Rishabh876
相关产品推荐
相关产品推荐

