【问题标题】:Could not resolve dependency: google-maps-react无法解决依赖关系:google-maps-react
【发布时间】:2022-02-09 12:38:27
【问题描述】:

这是我第一次从github克隆react项目

我做到了:

$ git clone <link>

之后:

npm install

但我遇到了 google-maps-react 的错误

$ npm install --save google-maps-react
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @iso/here@4.0.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"~0.14.8 || ^15.0.0 || ^16.0.0" from google-maps-react@2.0.6
npm ERR! node_modules/google-maps-react
npm ERR!   google-maps-react@"^2.0.6" 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\user\AppData\Local\npm-cache\eresolve-report.txt for a full report.

我试过了:

$ npm cache clean --force
$ npm install -g npm

,:

$npm config set legacy-peer-deps true

,:

npm install  --force

,:

npm install --save --legacy-peer-deps

,:

rm -rf node_modules

还有更多..

节点js版本:

16.13.2

反应版本:

17.0.2

npm 版本:

8.4.1

似乎没有任何效果

我错过了什么吗?

【问题讨论】:

标签: node.js reactjs npm installation next.js


【解决方案1】:

The project has a peer dependency 在 React 15 或 16 上并且您使用的是 17.0.2 - npm 错误说明了原因

如果您想按原样使用此库或更改该库的 package.json,请降级您的 react 版本,测试并向作者确认它们在 17.0.2 提出 PR 时表现良好

"peerDependencies": {
    "react": "~0.14.8 || ^15.0.0 || ^16.0.0",
    "react-dom": "~0.14.8 || ^15.0.0 || ^16.0.0"
  },

这里的 npm 在日志中告诉你原因

npm ERR! Fix the upstream dependency conflict, or retry

【讨论】:

    【解决方案2】:

    解决方案:

    该应用正在使用“纱线” 我现在可以在安装“yarn add node-sass”后运行应用程序

    【讨论】:

      猜你喜欢
      • 2016-02-16
      • 2017-02-20
      • 2022-07-27
      • 2018-05-25
      • 2020-07-01
      相关资源
      最近更新 更多