There are many npm ERR errors when downloading axios: npm ERR! code ERESOLVEnpm ERR! ERESOLVE could not resolve

Download error occurred:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolvenpm ERR!
npm ERR! while resolving: @vue/[email protected] ERR! Found: [email protected]
npm ERR! node_modules/eslint-plugin-vue
npm ERR!dev eslint-plugin-vue@""8.0.3"from the root projectnpm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint-plugin-vue@"'7.0.o"from @vue/[email protected] ERR! node_modules/@vue/eslint-config-standard
npm ERR!dev @vue/eslint-config-standard@"'6.1.0" from the root projectnpm ERR!
npm ERR! conflicting peer dependency: [email protected] ERR! node_modules/eslint-plugin-vue
npm ERR! peer eslint-plugin-vue@"'7.0.0"from@vue/[email protected] ERR!node_modules/@vue/eslint-config-standard
npm ERR!dev @vue/eslint-config-standard@"^6.1.e" from the root projectnpm ERR!
npm ERR! Fix the upstream dependency conflict,or retry
npm ERR! to accept an incorrect (and potentially broken)dependency resolution.npm ERR!
npm ERR! See D: \sInstallation\nodejs\node_cache\eresolve-report.txt for a fulispepoet.
 

Original download command:

npm i --save axios

Solution: Add: --legacy-peer-deps to the original download command

npm i --save axios --legacy-peer-deps

 That will solve the problem. You can check whether there is an "axios version number" in the package.json file. If so, the download will be successful.

To use axios: import first

import axios from 'axios'//要先导入

axios.get('url').then(res=>{console.log(res)})//再使用

Note: Any foreign modules used in the components under the src folder must be imported. Axios must also be imported after downloading it. Don’t forget it! ! ! ! 

learn by analogy:

Why the above error occurs:

  • This is because the npm version is too high. The requirements will be stricter after it is higher than 7;
  • npm -V can check the version of npm

The --legacy-peer-deps flag was introduced in v7 to bypass peerDependency automatic installation; it tells NPM to ignore issues with identical modules but different versions between various modules introduced in the project and continue with the installation.

So if the above error occurs when downloading other things in the future, just add: --legacy-peer-deps after the command  ;

For example, download swiper:

If  npm i --save swiper doesn't work, add --legacy-peer-deps and download again;

npm i --save swiper --legacy-peer-deps

Guess you like

Origin blog.csdn.net/a1598452168YY/article/details/128131845