我将开始与另一个开发人员一起开发一个原生react 项目,但在此之前我曾参与过另一个项目,它在Android模拟器上运行时没有出现错误.
我从https://github.com/ismail-benlaredj/ld-vetrinalive-reactnative和Run npm install
克隆了该项目,这导致了以下错误:
PS G:\Workspaces\React Native\ld-vetrinalive-reactnative> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: nativetestapp@0.0.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR! react@"18.0.0" from the root project
npm ERR! peer react@"*" from native-base@3.4.25
npm ERR! node_modules/native-base
npm ERR! native-base@"^3.4.25" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.2.0" from react-dom@18.2.0
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"*" from native-base@3.4.25
npm ERR! node_modules/native-base
npm ERR! native-base@"^3.4.25" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\DEV-ABDOU\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\DEV-ABDOU\AppData\Local\npm-cache\_logs\2022-12-17T21_35_51_753Z-debug.log
这是前eresolve-report.txt
名:
# npm resolution error report
2022-12-17T21:35:51.742Z
While resolving: nativetestapp@0.0.0
Found: react@18.0.0
node_modules/react
react@"18.0.0" from the root project
peer react@"*" from native-base@3.4.25
node_modules/native-base
native-base@"^3.4.25" from the root project
Could not resolve dependency:
peer react@"^18.2.0" from react-dom@18.2.0
node_modules/react-dom
peer react-dom@"*" from native-base@3.4.25
node_modules/native-base
native-base@"^3.4.25" from the root project
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.
Raw JSON explanation object:
{
"code": "ERESOLVE",
"current": {
"name": "react",
"version": "18.0.0",
"whileInstalling": {
"name": "nativetestapp",
"version": "0.0.0",
"path": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
},
"location": "node_modules/react",
"isWorkspace": false,
"dependents": [
{
"type": "prod",
"name": "react",
"spec": "18.0.0",
"from": {
"location": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
}
},
{
"type": "peer",
"name": "react",
"spec": "*",
"from": {
"name": "native-base",
"version": "3.4.25",
"whileInstalling": {
"name": "nativetestapp",
"version": "0.0.0",
"path": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
},
"location": "node_modules/native-base",
"isWorkspace": false,
"dependents": [
{
"type": "prod",
"name": "native-base",
"spec": "^3.4.25",
"from": {
"location": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
}
}
]
}
}
]
},
"currentEdge": {
"type": "prod",
"name": "react",
"spec": "18.0.0",
"from": {
"location": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
}
},
"edge": {
"type": "peer",
"name": "react",
"spec": "^18.2.0",
"error": "INVALID",
"from": {
"name": "react-dom",
"version": "18.2.0",
"whileInstalling": {
"name": "nativetestapp",
"version": "0.0.0",
"path": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
},
"location": "node_modules/react-dom",
"isWorkspace": false,
"dependents": [
{
"type": "peer",
"name": "react-dom",
"spec": "*",
"from": {
"name": "native-base",
"version": "3.4.25",
"whileInstalling": {
"name": "nativetestapp",
"version": "0.0.0",
"path": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
},
"location": "node_modules/native-base",
"isWorkspace": false,
"dependents": [
{
"type": "prod",
"name": "native-base",
"spec": "^3.4.25",
"from": {
"location": "G:\\Workspaces\\React Native\\ld-vetrinalive-reactnative"
}
}
]
}
}
]
}
},
"strictPeerDeps": false,
"force": false
}
- 我不知道我是否应该包括冗长的NPM日志(log)(让我知道).
问题是:
- 我不知道如何解释错误消息(resolve the peer dependencies)
- 控制台建议使用标志:
--force, or --legacy-peer-deps
,风险自负,我对此犹豫不决,因为它说
... to accept an incorrect (and potentially broken) dependency resolution.
这就是我在这里寻求帮助的原因.
关于SOF的类似问题:
React Native app's npm install fails due to conflicting versions of react and react-dom
到目前为止,我try 过的是:
我在网上看到的大多数答案都建议我更新我的全局REACT-Native-CLI,但根据文档here,他们要求您卸载它.
还有一些回答指出一些环境变量没有正确设置,这对我来说不是这样的,因为我的其他项目工作得很好.