简体   繁体   中英

Error npm install - unable to resolve dependency tree

After npm install, Error report:

While resolving: reactjs-simple-boilerplate@1.0.0

Found: webpack@4.46.0

node_modules/webpack

dev webpack@"^4.41.2" from the root project

Could not resolve dependency:

peer webpack@"^3.1.0" from extract-text-webpack-plugin@3.0.2

node_modules/extract-text-webpack-plugin

peer extract-text-webpack-plugin@">=0.3.8" from bootstrap-webpack@0.0.5

node_modules/bootstrap-webpack

bootstrap-webpack@"0.0.5" from the root project

enter image description here

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": "webpack",
    "version": "4.46.0",
    "whileInstalling": {
      "name": "reactjs-simple-boilerplate",
      "version": "1.0.0",
      "path": "/Users/mk/Kr/kr-application-bd786050/kr-site"
    },
    "location": "node_modules/webpack",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "dev",
        "name": "webpack",
        "spec": "^4.41.2",
        "from": {
          "location": "/Users/MK/Kr/kr-application-bd786050/kr-site"
        }
      }
    ]
  },
  "currentEdge": {
    "type": "dev",
    "name": "webpack",
    "spec": "^4.41.2",
    "from": {
      "location": "/Users/MK/Kr/kr-application-bd786050/kr-site"
    }
  },
  "edge": {
    "type": "peer",
    "name": "webpack",
    "spec": "^3.1.0",
    "error": "INVALID",
    "from": {
      "name": "extract-text-webpack-plugin",
      "version": "3.0.2",
      "whileInstalling": {
        "name": "reactjs-simple-boilerplate",
        "version": "1.0.0",
        "path": "/Users/MK/Kr/kr-application-bd786050/kr-site"
      },
      "location": "node_modules/extract-text-webpack-plugin",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "peer",
          "name": "extract-text-webpack-plugin",
          "spec": ">=0.3.8",
          "from": {
            "name": "bootstrap-webpack",
            "version": "0.0.5",
            "whileInstalling": {
              "name": "reactjs-simple-boilerplate",
              "version": "1.0.0",
              "path": "/Users/MK/Kr/kr-application-bd786050/kr-site"
            },
            "location": "node_modules/bootstrap-webpack",
            "isWorkspace": false,
            "dependents": [
              {
                "type": "prod",
                "name": "bootstrap-webpack",
                "spec": "0.0.5",
                "from": {
                  "location": "/Users/MK/Kr/kr-application-bd786050/kr-site"
                }
              }
            ]
          }
        }
      ]
    }
  },
  "strictPeerDeps": false,
  "force": false
}

Firstly try running webpack-cli init / webpack init and see if that fixes it.

Next try:

yarn remove extract-text-webpack-plugin

yarn add --dev extract-text-webpack-plugin@next

If neither work, then sometimes this can be a problem if the required package only works with a specific version of node/npm. If you don't already you should try using nvm for managing different versions of node which you can do by writing nvm use <version number> in your terminal.

Research your specific package that's causing dependency issues and see if it requires using a specific node.js version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM