如何克服 EAS 构建中为 native-base 和 Expo 的 ERESOLVE 错误?
How to overcome ERESOLVE errors within EAS build for native-base and 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
}
尽管所有本地调试和模拟器运行都没有问题,但当 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
如何克服这个问题,有什么想法吗?
年表:
native-base
于 2019 年添加到项目中,版本为 "^2.10.0"
。
- 升级到
"expo": "^44.0.0"
时,还需要在 2021-12 左右升级 native-base
。
- 在 2021-12 年,
native-base
升级为 "native-base": "^3.0.0"
- 直到最近它还在运行,包括 EAS 构建。
- 就在最近,在 2022 年 2 月 12 日之后,出于某些其他目的,我们更新了我们的代码,修改了
node_modules
,我们通过 EAS 构建和提交重新发布。但是即使 package.json
中的 "native-base": "^3.0.0"
条目没有改变,EAS 服务器中的 npm
步骤开始失败。
其他信息:
which build of the expo is failing android or ios.
ios
commands you are using to build.
eas build --platform ios --non-interactive
which package manager are you in this project ? yarn or npm.
我使用 yarn
但 eas build 似乎使用 npm
any other things which will be useful to replicate this error.
很遗憾,我没有任何其他线索。
似乎 native-base 搜索 "react-dom": "*"
但找不到它,所以以某种方式使用 "react-dom": "17.0.2"
并反过来寻找 "react": "17.0.2"
与世博会的 "react": "17.0.1"
.
所以添加 "react-dom": "17.0.1"
作为依赖解决了问题。通过这种方式 "react-dom": "*"
找到依赖于 Expo 版本 "react": "17.0.1"
的 "react-dom": "17.0.1"
。 (如果这个结论有误,请告诉我。)
以下是与 native-base
相关的版本,应使用这些版本,否则 npm install
将无法用于 Expo 44:
"react-dom": "17.0.1",
"react-native-safe-area-context": "3.1.9",
"react-native-svg": "12.1.0",
我也有类似的问题。
我通过在 package.json 文件中添加一行来解决它。
"scripts": {
"eas-build-pre-install": "npm install --save --legacy-peer-deps"
}
我有以下 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
}
尽管所有本地调试和模拟器运行都没有问题,但当 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
如何克服这个问题,有什么想法吗?
年表:
native-base
于 2019 年添加到项目中,版本为"^2.10.0"
。- 升级到
"expo": "^44.0.0"
时,还需要在 2021-12 左右升级native-base
。 - 在 2021-12 年,
native-base
升级为"native-base": "^3.0.0"
- 直到最近它还在运行,包括 EAS 构建。
- 就在最近,在 2022 年 2 月 12 日之后,出于某些其他目的,我们更新了我们的代码,修改了
node_modules
,我们通过 EAS 构建和提交重新发布。但是即使package.json
中的"native-base": "^3.0.0"
条目没有改变,EAS 服务器中的npm
步骤开始失败。
其他信息:
which build of the expo is failing android or ios.
ios
commands you are using to build.
eas build --platform ios --non-interactive
which package manager are you in this project ? yarn or npm.
我使用 yarn
但 eas build 似乎使用 npm
any other things which will be useful to replicate this error.
很遗憾,我没有任何其他线索。
似乎 native-base 搜索 "react-dom": "*"
但找不到它,所以以某种方式使用 "react-dom": "17.0.2"
并反过来寻找 "react": "17.0.2"
与世博会的 "react": "17.0.1"
.
所以添加 "react-dom": "17.0.1"
作为依赖解决了问题。通过这种方式 "react-dom": "*"
找到依赖于 Expo 版本 "react": "17.0.1"
的 "react-dom": "17.0.1"
。 (如果这个结论有误,请告诉我。)
以下是与 native-base
相关的版本,应使用这些版本,否则 npm install
将无法用于 Expo 44:
"react-dom": "17.0.1",
"react-native-safe-area-context": "3.1.9",
"react-native-svg": "12.1.0",
我也有类似的问题。 我通过在 package.json 文件中添加一行来解决它。
"scripts": {
"eas-build-pre-install": "npm install --save --legacy-peer-deps"
}