Конфликт зависимостей npm
Я работаю над проектом с Vue. Я запускаю Vue Cli и добавляю плагин Typescript. У меня есть несколько уязвимостей. Когда я бегу
npm audit fix
он не может разрешить конфликт зависимостей:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @typescript-eslint/eslint-plugin@4.33.0
npm ERR! Found: eslint@6.8.0
npm ERR! node_modules/eslint
npm ERR! dev eslint@"^6.7.2" from the root project
npm ERR! peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/eslint-plugin@4.33.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR! dev @typescript-eslint/eslint-plugin@"^4.33.0" from the root project
npm ERR! peer @typescript-eslint/eslint-plugin@"^4.4.0" from @vue/eslint-config-typescript@7.0.0
npm ERR! node_modules/@vue/eslint-config-typescript
npm ERR! dev @vue/eslint-config-typescript@"^7.0.0" from the root project
npm ERR! 9 more (@typescript-eslint/experimental-utils, eslint-utils, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/eslint-plugin@4.33.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR! dev @typescript-eslint/eslint-plugin@"^4.33.0" from the root project
npm ERR! peer @typescript-eslint/eslint-plugin@"^4.4.0" from @vue/eslint-config-typescript@7.0.0
npm ERR! node_modules/@vue/eslint-config-typescript
npm ERR! dev @vue/eslint-config-typescript@"^7.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@7.32.0
npm ERR! node_modules/eslint
npm ERR! peer eslint@"^5.0.0 || ^6.0.0 || ^7.0.0" from @typescript-eslint/eslint-plugin@4.33.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR! dev @typescript-eslint/eslint-plugin@"^4.33.0" from the root project
npm ERR! peer @typescript-eslint/eslint-plugin@"^4.4.0" from @vue/eslint-config-typescript@7.0.0
npm ERR! node_modules/@vue/eslint-config-typescript
npm ERR! dev @vue/eslint-config-typescript@"^7.0.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 /home/pau/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pau/.npm/_logs/2021-10-29T19_09_55_798Z-debug.log
Я использую
node
версия
v14.17.4
,
npm
версия
8.0.0
.
Вот мой
package.json
. Я настроил большую часть проекта с помощью Vue Cli, сейчас в версии
@vue/cli 4.5.14
.
{
"name": "uama.groundframework.frontend",
"version": "0.1.0",
"private": true,
"description": "## Project setup ``` npm install ```",
"author": "",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build && npm run copy_web-inf",
"lint": "vue-cli-service lint",
"capacitor:build": "vue-cli-service capacitor:build",
"capacitor:serve": "vue-cli-service capacitor:serve",
"copy": "ncp ./node_modules/@arcgis/core/assets ./public/assets",
"copy_web-inf": "ncp ./../../WEB-INF ./../../Servlets_Sockets/src/main/webapp/WEB-INF",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps && npx cap update android",
"postuninstall": "electron-builder install-app-deps"
},
"main": "background.js",
"dependencies": {
"@arcgis/core": "^4.20.2",
"@capacitor/android": "^2.0.0",
"@capacitor/cli": "^2.0.0",
"@capacitor/core": "^2.0.0",
"@capacitor/ios": "^2.0.0",
"@types/arcgis-js-api": "^4.20.1",
"axios": "^0.21.1",
"core-js": "^3.17.0",
"hammerjs": "^2.0.8",
"mathjs": "^9.4.4",
"ncp": "^2.0.0",
"vue": "^2.6.14",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.2",
"vuetify": "^2.5.8",
"vuex": "^3.5.1"
},
"devDependencies": {
"@types/electron-devtools-installer": "^2.2.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "^4.5.4",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-typescript": "^7.0.0",
"babel-eslint": "^10.1.0",
"dotenv-webpack": "^7.0.3",
"electron": "^13.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.38.2",
"sass-loader": "^8.0.0",
"typescript": "~4.1.5",
"vue-cli-plugin-capacitor": "~2.0.1",
"vue-cli-plugin-electron-builder": "~2.1.1",
"vue-cli-plugin-vuetify": "~2.0.7",
"vue-template-compiler": "^2.6.14",
"vuetify-loader": "^1.7.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript"
],
"parserOptions": {
"parser": "@typescript-eslint/parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"keywords": [],
"license": "ISC"
}
2 ответа
Ваш
package.json
имеет сочетание зависимостей разработчиков с версиями, которые начинаются с и теми, которые начинаются с. Вероятно, это связано с тем, что некоторые зависимости разработчиков были установлены со старыми версиями
npm
тот дефолт, который более консервативен, чем. В качестве первого шага измените 8
~
версии для
^
, Удалить
node_modules
и (если он существует)
package-lock.json
и беги
npm install
опять таки. Я тестировал это локально, и это не уменьшило количество обнаруженных уязвимостей, но уменьшило количество устаревших пакетов, что является шагом в правильном направлении.
Давайте упростим ситуацию, посмотрев только на результаты аудита для ваших производственных зависимостей и игнорируя (по крайней мере, на данный момент) проблемы в ваших зависимостях разработчика. сообщает только 5 вопросов, все умеренные. Бег
npm audit --only=prod --force fix
обновления
@capacitor/cli
с 2.x до 3.x.Это критическое изменение, поэтому вы захотите его протестировать, но если это сработает для вас, поздравляем, потому что
npm audit --only=prod
не сообщает об уязвимостях.
На этом этапе вы можете не беспокоиться о других проблемах, о которых сообщает
npm audit
. Однако, если вы хотите их исправить, вот потенциально утомительный / трудный путь, который я бы порекомендовал:
- Проведите ручной аудит всех ваших зависимостей разработчика, чтобы убедиться, что вы не включаете то, что вам не нужно. Возможно, у вас есть установленные вещи, которые вы не используете. Удалите их. Может быть, у вас установлены вещи, которые есть в наличии, но в действительности они вам не нужны. Подумайте об их удалении.
- Запустить
npm outdated
чтобы увидеть, что можно обновить вручную с помощью критического изменения. Попробуйте сделать эти обновления.
Надеюсь, это хоть немного поможет. Удачи.
Чтобы решить эту проблему, просто понизьте версию, предложенную npm.
Например.
НПМ ОШИБКА! код ERESOLVEnpm ERR! ERESOLVE не удалось разрешить npm ERR! НПМ ОШИБКА! При разрешении: @vue/ cli-plugin-eslint@ 4.5.15npm ERR! Найдено: eslint@7.32.0 npm ОШИБКА! node_modules/eslint НПМ ОШИБКА! одноранговый узел eslint@">= 4.12.1" от Babel-eslint@10.1.0 npm ERR! node_modules/babel-eslint НПМ ОШИБКА! dev Babel-eslint@"^10.1.0" из корневого проекта npm ERR! одноранговый узел eslint@">=5.0.0" из vue-eslint-parser@7.1.0npm ERR! node_modules/vue-eslint-parser npm ОШИБКА! vue-eslint-parser@"^7.0.0" из eslint-plugin-vue@6.2.2 npm ОШИБКА! node_modules/eslint-plugin-vue npm ОШИБКА! dev eslint-plugin-vue@"^6.2.2" из корневого проекта npm ERR! Еще 1 (корневой проект) npm ERR!
НПМ ОШИБКА! Не удалось разрешить зависимость:
НПМ ОШИБКА! одноранговый узел eslint@">= 1.6.0 < 7.0.0" из @vue/cli-plugin-eslint@4.5.15
НПМ ОШИБКА! node_modules/@vue/cli-plugin-eslint npm ОШИБКА! dev @vue/cli-plugin-eslint@"^4.5.15" из корневого проекта
Здесь говорится
Не удалось разрешить зависимость:
НПМ ОШИБКА! одноранговый узел eslint@">= 1.6.0 < 7.0.0" из @vue/cli-plugin-
эслинт@4.5.15
Поэтому обновите версию eslint между >= 1.6.0 < 7.0.0 в файле package.json, а затем запустите команду npm install. Если вы получите какую-либо ошибку, связанную с разрешением зависимости. Пожалуйста, следуйте этому
Спасибо.