如何克服针对 Native-Base 和 Expo 的 EAS 构建中的 ERESOLVE 错误?

Meh*_*lan 5 npm react-native native-base expo

我有以下package.json文件。主要目的是将 Expo 44 与 native-base (版本 )一起使用^3.0.0。我不明白为什么这样一个明显的组合不起作用。(网上找不到native-base,也推荐使用Expo版本。)

package.json:

{
    "main": "node_modules/expo/AppEntry.js",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "eject": "expo eject",
        "test": "node ./node_modules/jest/bin/jest.js --watchAll"
    },
    "dependencies": {
        "@expo/samples": "2.1.1",
        "@expo/vector-icons": "^12.0.0",
        "@react-native-async-storage/async-storage": "~1.15.0",
        "@react-native-community/datetimepicker": "4.0.0",
        "@react-native-community/netinfo": "7.1.3",
        "@react-native-picker/picker": "2.2.1",
        "expo": "^44.0.0",
        "expo-ads-admob": "~12.0.0",
        "expo-app-loading": "~1.3.0",
        "expo-apple-authentication": "~4.1.0",
        "expo-application": "~4.0.1",
        "expo-asset": "~8.4.5",
        "expo-auth-session": "~3.5.0",
        "expo-av": "~10.2.0",
        "expo-facebook": "~12.1.0",
        "expo-font": "~10.0.4",
        "expo-haptics": "~11.1.0",
        "expo-image-manipulator": "~10.2.0",
        "expo-random": "~12.1.1",
        "expo-screen-orientation": "~4.1.1",
        "expo-sharing": "~10.1.0",
        "expo-tracking-transparency": "~2.1.0",
        "moment": "^2.24.0",
        "native-base": "^3.0.0",
        "react": "17.0.1",
        "react-native": "0.64.3",
        "react-native-gesture-handler": "~2.1.0",
        "react-native-modal-datetime-picker": "^8.6.0",
        "react-native-picker-select": "^8.0.0",
        "react-native-progress": "^4.1.2",
        "react-native-progress-circle": "^2.1.0",
        "react-native-safe-area-context": "3.3.2",
        "react-native-svg": "12.1.1",
        "react-native-view-shot": "3.1.2",
        "react-native-webview": "11.15.0",
        "react-redux": "^6.0.0",
        "redux": "^4.0.1"
    },
    "devDependencies": {
        "babel-preset-expo": "9.0.1"
    },
    "resolutions": {},
    "private": true
}

Run Code Online (Sandbox Code Playgroud)

尽管所有本地调试和模拟器运行都没有问题,但当 EAS 尝试构建时,npm会看到以下错误(来自 )。

[stderr] npm ERR! code ERESOLVE
[stderr] npm
[stderr] ERR! ERESOLVE unable to resolve dependency tree
[stderr] npm ERR! 
[stderr] npm ERR! While resolving: undefined@undefined
[stderr] npm ERR! Found: react@17.0.1
[stderr] npm ERR! node_modules/react
[stderr] npm ERR!
[stderr] react@"17.0.1" from the root project
[stderr] npm ERR!   peer react@"*" from native-base@3.3.6
[stderr] npm ERR!   node_modules/native-base
[stderr] npm ERR!     native-base@"^3.0.0" from the root project
[stderr] npm ERR! 
[stderr] npm ERR! Could not resolve dependency:
[stderr] npm ERR! peer react@"17.0.2" from react-dom@17.0.2
[stderr] npm ERR! node_modules/react-dom
[stderr] npm ERR!   peer react-dom@"*" from native-base@3.3.6
[stderr] npm ERR!   node_modules/native-base
[stderr] npm ERR!     native-base@"^3.0.0" from the root project
[stderr] npm ERR! 
[stderr] npm ERR! Fix the upstream dependency conflict, or retry
[stderr] npm ERR! this command with --force, or --legacy-peer-deps
[stderr] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[stderr] npm ERR! 
[stderr] npm ERR! See /Users/expo/.npm/eresolve-report.txt for a full report.
[stderr] 
[stderr] npm ERR! A complete log of this run can be found in:
[stderr] npm ERR!     /Users/expo/.npm/_logs/2022-02-14T09_22_49_729Z-debug.log
npm exited with non-zero code: 1
Run Code Online (Sandbox Code Playgroud)

如何克服这个问题,有什么想法吗?

年表:

  • native-base早在 2019 年就被添加到项目中,"^2.10.0"版本为 .
  • 当升级到"expo": "^44.0.0"它时native-base,也需要在 2021-12 左右进行升级。
  • 2021-12 年native-base升级为"native-base": "^3.0.0"
  • 直到最近它才开始工作,包括 EAS 构建。
  • 就在最近,2022 年 2 月 12 日之后,出于其他一些目的,我们更新了代码,取消了代码node_modules,并通过 EAS 构建和提交重新发布。但即使"native-base": "^3.0.0"其中的条目package.json没有更改,npmEAS 服务器中的步骤也开始失败。

其他信息:

世博会的哪个版本在 Android 或 ios 上失败。

IOS

您用来构建的命令。

eas build --platform ios --non-interactive

你是这个项目中的哪个包管理器?纱线或 npm。

我使用yarn但 eas build 似乎使用npm

任何其他有助于复制此错误的东西。

不幸的是我没有任何其他线索。

Zet*_*eta 5

我也有类似的问题。我通过在 package.json 文件中添加一行解决了这个问题。

"scripts": {
"eas-build-pre-install": "npm install --save --legacy-peer-deps"
}
Run Code Online (Sandbox Code Playgroud)


Meh*_*lan 1

似乎基于本地的搜索 "react-dom": "*"并找不到它,所以以某种方式使用它"react-dom": "17.0.2",然后它又寻找"react": "17.0.2"与博览会冲突的"react": "17.0.1".

因此添加"react-dom": "17.0.1"依赖项解决了问题。通过这种方式"react-dom": "*"找到"react-dom": "17.0.1"与Expo的版本相关的内容"react": "17.0.1"。(如果这个结论有误,请告诉我。)

以下是与Expo 44相关的版本,native-base应使用这些版本,否则将失败:npm install

        "react-dom": "17.0.1",
        "react-native-safe-area-context": "3.1.9",
        "react-native-svg": "12.1.0",
Run Code Online (Sandbox Code Playgroud)

参考: https: //github.com/GeekyAnts/NativeBase/issues/4647