Vue project installation axios error report
Phenomenon
After the vue-cli builds the project, npm i axios -S
the following error is reported when entering the command to install axios.
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS D:\code\front\demo-eslint> npm i axios -S
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @vue/eslint-config-standard@6.1.0
npm ERR! Found: eslint-plugin-vue@8.7.1
npm ERR! node_modules/eslint-plugin-vue
npm ERR! dev eslint-plugin-vue@"^8.0.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0
npm ERR! node_modules/@vue/eslint-config-standard
npm ERR! dev @vue/eslint-config-standard@"^6.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint-plugin-vue@7.20.0
npm ERR! node_modules/eslint-plugin-vue
npm ERR! peer eslint-plugin-vue@"^7.0.0" from @vue/eslint-config-standard@6.1.0
npm ERR! node_modules/@vue/eslint-config-standard
npm ERR! dev @vue/eslint-config-standard@"^6.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 C:\Users\sky\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sky\AppData\Local\npm-cache\_logs\2022-11-10T06_23_49_274Z-debug-0.log
Solution
The command npm i axios -S --legacy-peer-deps
can be changed to install successfully.
added 6 packages, and audited 1010 packages in 4s
133 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Cause Analysis
In some versions of NPM, peerDependencies (peer dependencies, which represent the hosting relationship between packages and packages) are installed by default.
In many cases, this leads to version conflicts between individual packages, which breaks the installation process.
The purpose of –legacy-peer-deps is to bypass the automatic installation of peerDependency. It tells npm to ignore the problems of the same modules but different versions between the modules introduced in the project and continue to install, ensuring that the imported dependencies are used by themselves Different versions of modules coexist.
Personally, I configured the eslint project and then installed axios to report an error. I suspect that there is a conflict between these two dependencies.