NodeJS NPM依赖关系解析冲突

q43xntqr  于 2023-02-03  发布在  Node.js
关注(0)|答案(3)|浏览(173)

当我运行node install时,我得到以下输出:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: google-map-react@2.1.10
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   react@"^18.1.0" from the root project
npm ERR!   peer react@">=16.3" from @deck.gl/react@8.7.8
npm ERR!   node_modules/@deck.gl/react
npm ERR!     @deck.gl/react@"8.7.8" from deck.gl@8.7.8
npm ERR!     node_modules/deck.gl
npm ERR!       deck.gl@"^8.7.8" from the root project
npm ERR!   15 more (@emotion/react, @emotion/styled, @mui/base, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0 || ^17.0.0" from google-map-react@2.1.10
npm ERR! node_modules/google-map-react
npm ERR!   google-map-react@"^2.1.10" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"^16.0.0 || ^17.0.0" from google-map-react@2.1.10
npm ERR!   node_modules/google-map-react
npm ERR!     google-map-react@"^2.1.10" 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.

这是我的package.json文件:

{
    "name": "frontend",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@emotion/react": "^11.9.0",
        "@emotion/styled": "^11.8.1",
        "@mui/icons-material": "^5.6.2",
        "@mui/material": "^5.6.3",
        "deck.gl": "^8.7.8",
        "react": "^18.1.0",
        "react-dom": "^18.1.0",
        "react-router": "^6.3.0",
        "react-router-dom": "^5.1.2",
        "react-scripts": "5.0.1",
        "react-transition-group": "^4.3.0"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    }
}

我已经尝试了npm install --legacy-peer-depsnpm install --force,没有一个改变了错误信息。我还尝试了npm install --legacy-peer-deps --save google-maps-react,看看我是否必须为每个包单独执行此操作,没有运气。我知道这个错误相对常见,它与npm版本和可怕的破坏性更改有关。
有人知道我还能采取什么措施吗?

62lalag4

62lalag41#

我解决了这个问题后,运行npm install --legacy-peer-deps从我的pc版本的节点18.0.0到最新的16 LTS。

ax6ht2ek

ax6ht2ek2#

找到:响应@18.1.0 npm错误!对等响应@"^16.8.0||^17.0.0英寸

  1. npm配置集传统对等部署为真
  2. npm安装--保存--传统对等部署
  3. npm安装--强制
wgx48brx

wgx48brx3#

    • 我通过运行以下说明解决了此问题**
  1. npm配置集传统对等部署为真
  2. npm安装--保存--传统对等部署
  3. npm安装--强制

节点. js #Reactjs #npm

相关问题