【问题标题】:Unable to update React and React Native with npm无法使用 npm 更新 React 和 React Native
【发布时间】:2021-03-12 03:48:07
【问题描述】:

我正在尝试更新到 react@17.0.1 和 react-native@0.64.0-rc.0 但我遇到了以下错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react@16.13.1
npm ERR! node_modules/react
npm ERR!   react@"16.13.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from react-native@0.64.0-rc.0
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.64.0-rc.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.

我目前正在使用 React 16.13.1 和 React Native 0.63.4。关于如何解决这个问题的任何想法?

只需使用 --verbose 运行它,也得到了这个:

npm notice 
npm verb stack Error: unable to resolve dependency tree
npm verb stack     at Arborist.[failPeerConflict] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1143:25)
npm verb stack     at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1242:32)
npm verb stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:851:46
npm verb stack     at Array.map (<anonymous>)
npm verb stack     at Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:851:8)
npm verb stack     at processTicksAndRejections (node:internal/process/task_queues:94:5)
npm verb stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:209:7)
npm verb stack     at async Promise.all (index 1)
npm verb stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
npm verb stack     at async Install.install (/usr/local/lib/node_modules/npm/lib/install.js:120:5)
npm verb cwd /Users/x/Development/App
npm verb Darwin 20.3.0
npm verb argv "/usr/local/Cellar/node/15.9.0/bin/node" "/usr/local/bin/npm" "install" "react@17.0.1" "--verbose"
npm verb node v15.9.0
npm verb npm  v7.6.2

【问题讨论】:

    标签: react-native npm


    【解决方案1】:

    您可能正在运行 npm 版本 7。如果是这样,请尝试使用 --legacy-peer-deps 运行您的 npm install 命令。

    npm 版本 6 对依赖冲突的处理相对宽松,而 npm 版本 7 更严格,因此在 npm 6 没有的情况下会失败。要返回 npm 6 依赖解析算法,请使用 --legacy-peer-deps 标志。另一种选择是降级到 npm 6。

    【讨论】:

      猜你喜欢
      • 2019-03-27
      • 2020-02-15
      • 1970-01-01
      • 2021-01-23
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-27
      相关资源
      最近更新 更多