最近编辑开发过的项目,遇到问题如下:
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @vue/cli-plugin-eslint@4.5.17
npm ERR! Found: eslint@7.32.0
npm ERR! node_modules/eslint
npm ERR! dev eslint@"7.32.0" from the root project
npm ERR! peer eslint@">= 5.0.0" from @vue/eslint-config-prettier@6.0.0
npm ERR! node_modules/@vue/eslint-config-prettier
npm ERR! dev @vue/eslint-config-prettier@"^6.0.0" from the root project
npm ERR! 5 more (eslint-config-prettier, eslint-plugin-prettier, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">= 1.6.0 < 7.0.0" from @vue/cli-plugin-eslint@4.5.17
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR! dev @vue/cli-plugin-eslint@"^4.5.15" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@6.8.0
npm ERR! node_modules/eslint
npm ERR! peer eslint@">= 1.6.0 < 7.0.0" from @vue/cli-plugin-eslint@4.5.17
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR! dev @vue/cli-plugin-eslint@"^4.5.15" 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!
npm ERR! For a full report see:
npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-08-20T14_34_59_044Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-08-20T14_34_59_044Z-debug-0.log
尝试使用
npm cache clean --force 清除缓存无效
简单升级了依赖版本:在 `package.json` 文件中确保依赖版本能够兼容。例如:
json
"dependencies": {
"@vue/cli-plugin-eslint": "^4.5.17",
"@vue/eslint-config-prettier": "^6.0.0",
"eslint": "^7.32.0"
}
不管用
重新安装依赖:尝试使用 ` --force` npm i --force
: 使用 --force
标志时,npm 将强制安装指定的依赖,即使它们的版本可能与其他依赖项不兼容。这可能会导致依赖之间的版本冲突或其他问题,因为它将忽略版本的兼容性检查。在使用这个标志时,你需要非常小心,因为它可能会导致不稳定的依赖关系,甚至是项目破坏。或 `--legacy-peer-deps` npm i --legacy-peer-deps
: 使用 --legacy-peer-deps
标志时,npm 将尝试使用旧的依赖解析算法,该算法可能会导致安装依赖项,即使它们与其他依赖项不兼容。这是为了允许安装一些在新的解析算法中可能被视为不兼容的依赖项。尽管这可能会解决一些依赖解析问题,但同样需要小心使用,因为它也可能导致不稳定的依赖关系。
在使用npm i --legacy-peer-deps 提示:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@achrinza/node-ipc@9.2.2',
npm WARN EBADENGINE required: { node: '8 || 10 || 12 || 14 || 16 || 17' },
npm WARN EBADENGINE current: { node: 'v18.12.1', npm: '9.1.1' }
npm WARN EBADENGINE }
原来是版本安装高了,最大只支持17
完美源码 » 怎么查vue项目中使用的Node版本?