如何解决npm 对等依赖冲突
我下载了一个项目,但它没有 package-lock.json
文件。当我运行 npm install
时,有冲突。错误信息:
root@fb3391c63c7f:/app/avatar/avatar-h5# npm install --registry=https://registry.npm.taobao.org
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: avatar@3.2.0
npm ERR! Found: vue@2.6.10
npm ERR! node_modules/vue
npm ERR! vue@"2.6.10" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"3.0.5" from @vue/compiler-sfc@3.0.5
npm ERR! node_modules/@vue/compiler-sfc
npm ERR! peer @vue/compiler-sfc@"^3.0.0-beta.14" from @vue/cli-service@4.5.10
npm ERR! node_modules/@vue/cli-service
npm ERR! peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.4.4
npm ERR! node_modules/@vue/cli-plugin-babel
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.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-01-18T21_53_07_044Z-debug.log
我阅读了很多文档并发现 @vue/cli-plugin-babel@4.4.4
将安装最新的 @vue/cli-service@4.5.10
。
如何安装它与 vue@2.6.10
package.json 文件
{
"name": "avatar","version": "3.2.0","scripts": {
"dev": "vue-cli-service serve","build:prod": "vue-cli-service build","build:stage": "vue-cli-service build --mode staging","preview": "node build/index.js --preview","lint": "eslint --ext .js,.vue src","test:unit": "jest --clearCache && vue-cli-service test:unit","test:ci": "npm run lint && npm run test:unit","svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml","new": "plop"
},"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},"lint-staged": {
"src/**/*.{js,vue}": [
"eslint --fix","git add"
]
},"keywords": [
"vue","admin","dashboard","element-ui","boilerplate","admin-template","management-system"
],"repository": {
"type": "git","url": "https://gitee.com/fairyfleet/avatar.git"
},"dependencies": {
"@riophae/vue-treeselect": "0.4.0","axios": "0.18.1","clipboard": "2.0.4","core-js": "3.6.5","echarts": "4.2.1","element-ui": "2.13.2","file-saver": "2.0.1","js-beautify": "1.10.2","fuse.js": "3.4.4","js-cookie": "2.2.0","jsencrypt": "3.0.0-rc.1","normalize.css": "7.0.0","nprogress": "0.2.0","path-to-regexp": "2.4.0","screenfull": "4.2.0","sortablejs": "1.8.4","vue": "2.6.10","vue-count-to": "1.0.13","quill": "1.3.7","vue-cropper": "0.4.9","vue-router": "3.0.2","vue-splitpane": "1.0.4","vuedraggable": "2.20.0","vuex": "3.1.0"
},"devDependencies": {
"@vue/cli-plugin-babel": "4.4.4","@vue/cli-plugin-eslint": "4.4.4","@vue/cli-plugin-unit-jest": "4.4.4","@vue/cli-service": "4.4.4","@vue/test-utils": "1.0.0-beta.29","autoprefixer": "9.5.1","babel-eslint": "10.1.0","babel-jest": "23.6.0","babel-plugin-dynamic-import-node": "2.3.3","chalk": "2.4.2","chokidar": "2.1.5","connect": "3.6.6","eslint": "6.7.2","eslint-plugin-vue": "6.2.2","html-webpack-plugin": "3.2.0","husky": "1.3.1","lint-staged": "8.1.5","mockjs": "1.0.1-beta3","plop": "2.3.0","runjs": "4.3.2","node-sass": "4.14.1","sass-loader": "8.0.2","script-ext-html-webpack-plugin": "2.1.3","script-loader": "0.7.2","serve-static": "1.13.2","svg-sprite-loader": "4.1.3","svgo": "1.2.0","vue-template-compiler": "2.6.10"
},"engines": {
"node": ">=8.9","npm": ">= 3.0.0"
},"browserslist": [
"> 1%","last 2 versions"
]
}
解决方法
同样的问题。它只发生在较新版本的 npm 上。您可以通过使用 LTS 14.15 版本的 NodeJS 来暂时修复它。
在 Linux/MacOS 上:
nvm use --lts
否则:
npm install -g npm@6.14.8
,
为我解决这个问题的方法只是删除 node_modules 文件夹,然后将软件包版本粘贴到软件包 json 文件中并运行 npm install。
,npm install -g npm@6.14.8
这也适用于 Windows。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。