npm을 통해 vue-router를 설치할 수 없습니다
P粉496886646
P粉496886646 2024-02-17 10:49:32
0
1
293

vue-router를 설치하고 싶은데 오류가 발생했습니다

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: routing01@1.0.0
npm ERR! Found: vue@2.6.14
npm ERR! node_modules/vue
npm ERR!   vue@"^2.5.11" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.2.0" from vue-router@4.0.15
npm ERR! node_modules/vue-router
npm ERR!   vue-router@"4" 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\Peyman\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\Peyman\AppData\Local\npm-cache\_logs22-05-31T07_48_48_170Z-debug-0.log

P粉496886646
P粉496886646

모든 응답(1)
P粉135292805

문제는 vuevue-router 버전이 호환되지 않는다는 것입니다.

  • vue@2 需要 vue-router@3
  • vue@3 需要 vue-router@4

오류 메시지는 vue@2.6.14,并且您正在尝试安装 vue-router@4.0.15。请注意,npm install -S vue-router(不带版本说明符)默认为最新版本,即当前 4.0.15이(가) 있음을 나타냅니다.

오류 메시지에 제안된 --force--legacy-peer-deps npm 플래그를 사용하지 마세요. 이렇게 하면 호환되지 않는 패키지만 설치되고 런타임 오류가 발생할 수 있습니다.

솔루션

빠른 수정은 설치하는 것입니다 vue-router@3:

으아아아

또는 Vue 3으로 업그레이드할 수 있습니다. 이를 위해서는 제거가 필요합니다 vue-template-compiler (Vue 2 的模板编译器)并安装 @vue/compiler-sfc(Vue 3용 템플릿 컴파일러):

으아아아
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!