【问题标题】:npm install error while use webpack, Could not resolve dependency使用 webpack 时出现 npm 安装错误,无法解析依赖项
【发布时间】:2021-07-07 04:01:45
【问题描述】:

错误如下:

> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: webpack@3.12.0
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^3.5.6" from the root project
npm ERR!   peer webpack@"2 || 3 || 4" from _babel-loader@7.1.5@babel-loader@7.1.5
npm ERR!   node_modules/_babel-loader@7.1.5@babel-loader
npm ERR!   5 more (_html-webpack-plugin@2.30.1@html-webpack-plugin, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^2.0.0" from _strip-pragma-loader@1.0.0@strip-pragma-loader@1.0.0
npm ERR! node_modules/_strip-pragma-loader@1.0.0@strip-pragma-loader
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 /home/agou-ops/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/agou-ops/.npm/_logs/2021-04-12T02_49_11_062Z-debug.log

debug.log文件内容:

包版本和系统

  • npm: 7.6.3
  • webpack:3.12.0
  • 系统:Ubuntu 20.04

我应该如何解决它?

【问题讨论】:

    标签: node.js npm webpack leaflet webpack-2


    【解决方案1】:

    降级到较低的 npm 版本,例如,

    npm install npm@6
    

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。

      如果您不使用相关包,请尝试使用 --force 运行命令。

      例如

      npm install --verbose --force
      

      【讨论】:

        【解决方案3】:

        npm@7 比以前的版本具有更严格的依赖关系解析。如果您可以在根项目中更新webpack 的版本,那可能会解决它。另一个简单的快速尝试是npm install --legacy-peer-deps

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-03-15
          • 1970-01-01
          • 1970-01-01
          • 2021-05-01
          • 2018-05-30
          • 1970-01-01
          相关资源
          最近更新 更多