Vue项目安装axios报错
生活随笔
收集整理的這篇文章主要介紹了
Vue项目安装axios报错
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Vue項目安裝axios報錯
- 現象
- 解決方法
- 原因分析
現象
vue-cli搭建完項目,輸入命令npm i axios -S安裝axios時報如下錯誤。
Windows PowerShell 版權所有 (C) Microsoft Corporation。保留所有權利。嘗試新的跨平臺 PowerShell https://aka.ms/pscore6PS 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解決方法
命令更改為npm i axios -S --legacy-peer-deps即可安裝成功。
added 6 packages, and audited 1010 packages in 4s133 packages are looking for fundingrun `npm fund` for detailsfound 0 vulnerabilities原因分析
部分版本NPM中會默認安裝peerDependencies(同伴依賴,它表示包和包之間的宿主關系)。
在很多情況下,這會導致各個包之間的版本沖突,從而中斷安裝過程。
–legacy-peer-deps目的是繞過peerDependency自動安裝,它告訴 npm忽略項目中引入的各個modules之間的相同modules但不同版本的問題并繼續安裝,保證各個引入的依賴之間對自身所使用的不同版本modules共存。
個人是配置eslint的項目再安裝axios報錯,懷疑是這兩個依賴之間沖突。
總結
以上是生活随笔為你收集整理的Vue项目安装axios报错的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: eNSP常用命令 华为模拟器eNSP常用
- 下一篇: PBRT