as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
原生
Skip to main content
本文档将指导您解决在将应用迁移到React Native 0.83时会遇到的常见错误。

npm错误

ERESOLVE — 对等依赖项解析失败

错误:ERESOLVE unable to resolve dependency tree 修复:
  1. 全新安装:
  2. 如果仍失败,请根据错误输出 (“已发现: X” vs ” 无法解决: Y”) 来识别冲突
  3. 确保所有依赖版本均符合目标版本RN 0.83的要求
  4. 切勿使用--legacy-peer-deps — 它会掩盖冲突,进而导致运行时错误

对等React版本冲突(已缓存0.72)

错误:peer react@... from react-native@0.72或Conflicting peer dependency: react@19 原因: node_modules中已缓存的react-native@0.72.0与React 19冲突。 修复:
验证package.json是否为"react": "19.2.0"、"react-native": "0.83.0"、"@types/react": "^19.2.0"。

@types/react版本不匹配

错误:Found: @types/react@18/peerOptional @types/react@^19 修复: 更新devDependencies:

ts-jest对等依赖项冲突

错误:peer jest@^28.0.0 from ts-jest 修复: 更新ts-jest以匹配jest v29:

TypeScript错误

未找到tsconfig.json扩展

错误:TS6053: File '@react-native/typescript-config/tsconfig.json' not found 修复:
(移除/tsconfig.json后缀)

allowImportingTsExtensions / customConditions

错误:TS5096或TS5098 修复: 向tsconfig.json添加覆盖项:

使用isolatedModules重新导出类型

错误:TS1205: Re-exporting a type when 'isolatedModules' is enabled 修复:

CMake和原生版本错误

未找到keplerscript目标

错误:Target links to keplerscript-2 but the target was not found 修复: 在cxx/CMakeLists.txt中:

不支持C++20功能

错误:C++20 features not supported 修复: 确保已安装CMake 3.22以上版本,且支持C++20编译器(GCC 10以上版本或Clang 12以上版本)。

Metro Bundler错误

找不到模块 ‘@react-native/babel-preset’

修复:

无法解析模块

修复:

Jest错误与测试错误

SyntaxError: 无法在模块(平台包)之外使用导入语句

原因: @amazon-devices/react-native-kepler的某些4.0.x版本(例如4.0.1)在其jest设置中使用了ES模块。 修复: 在jest.config中的transformIgnorePatterns添加:

无法读取未定义的属性 (Dimensions/PixelRatio/StyleSheet)

原因: React 19更改了模拟行为。这些API无法自动模拟。 修复: 将模拟添加到jest.setup.js(参见步骤 7.2)。

无法在已卸载的测试渲染器上访问.root

原因: 将@testing-library/react-native``render()打包在ReactTestRenderer.act()中。 修复: 移除act()包装 — 由测试库内部处理(请参阅步骤7.4)。

缺失NativeAnimatedModule方法存根

**错误:**在NativeAnimatedHelper.js中Cannot read properties of undefined (reading 'apply') 原因: RN 0.83动画系统在NativeAnimatedModule上调用了23种特定方法。 修复: 将完整模拟添加到jest.setup.js(请参阅步骤7.2)。

导航栈计时器泄漏

错误:You are trying to import a file after the Jest environment has been torn down 修复:

已在keplerscript-native-ui-components中嵌套react-native

错误: 来自keplerscript-native-ui-components/node_modules/react-native的Flow/ESM解析错误 原因:kepler-ui-components@2.x捆绑了自己的react-native副本。 修复: 更新到@amazon-devices/kepler-ui-components@3.0.0。

运行时错误

运行时模块加载失败: IKeplerScript_2_0

**原因:**manifest.toml仍引用旧版Kepler 2.x运行时。 修复: 更新manifest.toml中的runtime-module路径(请参阅第4阶段)。

未找到模块’@amazon-devices/keplerscript-commonmodules’

原因: 您的应用使用JavaScript系统捆绑,但该程序包尚未安装。标准应用不需要此程序包。 修复: 添加到devDependencies:

无法识别的build-vega命令

原因:@react-native-community/cli已移除。 修复: 保留在devDependencies中:

ReferenceError: 未定义useState

修复: 添加显式导入:
最后修改于 2026年10月28日