美文网首页web前端
npm ERR! Conflicting peer depend

npm ERR! Conflicting peer depend

作者: 姜治宇 | 来源:发表于2023-02-07 11:39 被阅读0次

    webpack版本问题

    今天在重新安装node_modules时,遇到了如下错误:

    $ npm install
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE could not resolve
    npm ERR!
    npm ERR! While resolving: mysite@0.0.2
    npm ERR! Found: webpack@4.46.0
    npm ERR! node_modules/webpack
    npm ERR!   webpack@"^5.75.0" from the root project
    npm ERR!   peer webpack@"^4.0.0" from css-loader@1.0.1
    npm ERR!   node_modules/css-loader
    npm ERR!     css-loader@"^6.7.3" from the root project
    npm ERR!   7 more (html-webpack-plugin, istanbul-instrumenter-loader, ...)
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! babel-loader@"^9.1.2" from the root project
    npm ERR!
    npm ERR! Conflicting peer dependency: webpack@5.75.0
    npm ERR! node_modules/webpack
    npm ERR!   peer webpack@">=5" from babel-loader@9.1.2
    npm ERR!   node_modules/babel-loader
    npm ERR!     babel-loader@"^9.1.2" 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\admin\AppData\Local\npm-cache\eresolve-report.txt for a fu                                 ll report.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\admin\AppData\Local\npm-cache\_logs\2023-02-08T03_26_58_05                                 6Z-debug-0.log
    
    

    解决方案

    运行以下命令:

    npm install --save-dev html-webpack-plugin --legacy-peer-deps
    
    $ npm install --save-dev html-webpack-plugin --legacy-peer-deps
    npm WARN idealTree Removing dependencies.html-webpack-plugin in favor of devDepe                                 ndencies.html-webpack-plugin
    npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprec                                 ated
    npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-m                                 ap-url#deprecated
    npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/sour                                 ce-map-resolve#deprecated
    npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#dep                                 recated
    npm WARN deprecated streamroller@0.7.0: 0.x is no longer supported. Please upgra                                 de to 3.x or higher.
    npm WARN deprecated date-format@1.2.0: 1.x is no longer supported. Please upgrad                                 e to 4.x or higher.
    npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, fl                                 atted is its successor.
    npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates                                  since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
    npm WARN deprecated log4js@3.0.6: 3.x is no longer supported. Please upgrade to                                  6.x or higher.
    npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and                                  not recommended for usage due to the number of issues. Because of the V8 engine                                  whims, feature detection in old core-js versions could cause a slowdown up to 10                                 0x even if nothing is polyfilled. Some versions have web compatibility issues. P                                 lease, upgrade your dependencies to the actual version of core-js.
    
    added 988 packages in 1m
    

    如果有patch补丁的,可以再次运行npm install,发现补丁已经被打进去了:

    $ npm install
    
    > mysite@0.0.2 postinstall
    > patch-package
    
    patch-package 6.5.1
    Applying patches...
    tui-jsdoc-template@1.2.2 ✔
    
    added 4 packages, removed 2 packages, and changed 1 package in 6s
    
    

    相关文章

      网友评论

        本文标题:npm ERR! Conflicting peer depend

        本文链接:https://www.haomeiwen.com/subject/ornxkdtx.html