You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 23:15:44