服务器npm安装eslint-config-airbnb-base@13.1.0失败(404+依赖冲突)求助
解决eslint-config-airbnb-base@13.1.0与eslint@6.0.1的依赖冲突问题
你遇到的不是404错误,而是npm依赖版本冲突:项目中安装的eslint@6.0.1,与eslint-config-airbnb-base@13.1.0要求的peer依赖不匹配——后者仅支持eslint@4.19.1或5.3.0,版本范围冲突导致安装失败。
报错日志如下:
npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: eslint-config-airbnb-base@13.1.0 npm ERR! Found: eslint@"6.0.1" npm ERR! node_modules/eslint npm ERR! dev eslint@"6.0.1" from the root project npm ERR! peer eslint@"2.x - 6.x" from eslint-plugin-import@2.18.0 npm ERR! node_modules/eslint-plugin-import npm ERR! dev eslint-plugin-import@"2.18.0" from the root project npm ERR! peer eslint-plugin-import@"^2.14.0" from eslint-config-airbnb-base@13.1.0 npm ERR! node_modules/eslint-config-airbnb-base npm ERR! dev eslint-config-airbnb-base@"13.1.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer eslint@"^4.19.1 || ^5.3.0" from eslint-config-airbnb-base@13.1.0 npm ERR! node_modules/eslint-config-airbnb-base npm ERR! dev eslint-config-airbnb-base@"13.1.0" from the root project npm ERR! npm ERR! Conflicting peer dependency: eslint@5.16.0 npm ERR! node_modules/eslint npm ERR! peer eslint@"^4.19.1 || ^5.3.0" from eslint-config-airbnb-base@13.1.0 npm ERR! node_modules/eslint-config-airbnb-base npm ERR! dev eslint-config-airbnb-base@"13.1.0" 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 /root/.npm/eresolve-report.txt for a full report.
以下三种方法可解决问题:
降低eslint版本到兼容范围:将项目中的eslint降级到5.16.0(符合airbnb-base@13.1.0的要求),执行命令:
npm install eslint@5.16.0 --save-dev之后重新执行依赖安装命令即可。
使用npm兼容参数跳过冲突:若不想调整版本,可使用
--legacy-peer-deps忽略peer依赖冲突(推荐,不会强制修改依赖树),或--force强制安装(可能导致依赖树不稳定):npm install --legacy-peer-deps # 或者 npm install --force升级airbnb-base到兼容eslint6的版本:eslint-config-airbnb-base@14.x版本开始支持eslint6,直接升级该包:
npm install eslint-config-airbnb-base@^14.0.0 --save-dev升级后再安装依赖,版本即可匹配。
内容的提问来源于stack exchange,提问作者Binayak
相关产品推荐
相关产品推荐

