npm 安装失败(无法解析依赖树)
npm install fails (unable to resolve dependency tree)
尝试减少任何变化的变量并使用新的代码。它们不是 node-module
包或 package-lock.json
。我 运行 npm install
我得到这个错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native-screens@2.15.2
npm ERR! node_modules/react-native-screens
npm ERR! react-native-screens@"~2.15.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-screens@"^1.0.0 || ^1.0.0-alpha" from react-navigation-drawer@1.4.0
npm ERR! node_modules/react-navigation-drawer
npm ERR! react-navigation-drawer@"^1.4.0" 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 /Users/myname/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/myname/.npm/_logs/2021-05-22T01_16_02_351Z-debug.log
如果我通过 --force
或 npm install --legacy-peer-deps
安装,我会得到一堆标记为过时的文件,当我 运行 npm update
时,我会得到同样的错误。我也尝试过清除 npm 的缓存,但没有成功 npm cache clean
。我不知道为什么会发生这种情况,因为没有节点模块文件夹或任何安装它的东西在我的 node_modules/react-native-screens
下给出错误...它们还没有 node_modules 文件夹。是什么原因造成的,我该如何解决?
编辑:
我 运行 npm update -g
,然后 npm audit fix
然后我得到一个错误:
code ERESOLVE
ERESOLVE unable to resolve dependency tree
While resolving: Sculp latest app@undefined
Found: react-native-screens@2.15.2
node_modules/react-native-screens
react-native-screens@“~2.15.0” from the root project
所以我 运行 expo install react-native-screens
发现它找不到 expo...检查了我的文件夹,我的 node_module
文件夹不见了。就像它从未存在或从未安装过一样。
编辑:
我已经尝试了下面列出的所有方法,它给出了 运行dom 错误,我无法修复它 undefined is not an object (evaluating ‘_core.ThemeColors.light’)
我用谷歌搜索了这个,主要的解决方案之一是删除 npm 和 package-lock.json 并重新安装,但这让我回到了开始的地方。
尝试复制您的 src 文件夹和 package.json 文件并初始化另一个 react-native(新)并替换源 src 文件夹和 package.json 文件并重新输入 npm install。
您可以在命令行中使用 --force,但稍后您可能必须处理损坏的 react-native 依赖项。无论如何,还有其他方法可以处理这种损坏的依赖关系。
对我有用:
npm install --save --legacy-peer-deps
尝试以下方法:
npm add react-native
expo install (your needed module)
尝试减少任何变化的变量并使用新的代码。它们不是 node-module
包或 package-lock.json
。我 运行 npm install
我得到这个错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native-screens@2.15.2
npm ERR! node_modules/react-native-screens
npm ERR! react-native-screens@"~2.15.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-screens@"^1.0.0 || ^1.0.0-alpha" from react-navigation-drawer@1.4.0
npm ERR! node_modules/react-navigation-drawer
npm ERR! react-navigation-drawer@"^1.4.0" 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 /Users/myname/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/myname/.npm/_logs/2021-05-22T01_16_02_351Z-debug.log
如果我通过 --force
或 npm install --legacy-peer-deps
安装,我会得到一堆标记为过时的文件,当我 运行 npm update
时,我会得到同样的错误。我也尝试过清除 npm 的缓存,但没有成功 npm cache clean
。我不知道为什么会发生这种情况,因为没有节点模块文件夹或任何安装它的东西在我的 node_modules/react-native-screens
下给出错误...它们还没有 node_modules 文件夹。是什么原因造成的,我该如何解决?
编辑:
我 运行 npm update -g
,然后 npm audit fix
然后我得到一个错误:
code ERESOLVE
ERESOLVE unable to resolve dependency tree
While resolving: Sculp latest app@undefined
Found: react-native-screens@2.15.2
node_modules/react-native-screens
react-native-screens@“~2.15.0” from the root project
所以我 运行 expo install react-native-screens
发现它找不到 expo...检查了我的文件夹,我的 node_module
文件夹不见了。就像它从未存在或从未安装过一样。
编辑:
我已经尝试了下面列出的所有方法,它给出了 运行dom 错误,我无法修复它 undefined is not an object (evaluating ‘_core.ThemeColors.light’)
我用谷歌搜索了这个,主要的解决方案之一是删除 npm 和 package-lock.json 并重新安装,但这让我回到了开始的地方。
尝试复制您的 src 文件夹和 package.json 文件并初始化另一个 react-native(新)并替换源 src 文件夹和 package.json 文件并重新输入 npm install。
您可以在命令行中使用 --force,但稍后您可能必须处理损坏的 react-native 依赖项。无论如何,还有其他方法可以处理这种损坏的依赖关系。
对我有用:
npm install --save --legacy-peer-deps
尝试以下方法:
npm add react-native
expo install (your needed module)