vue と vuex のインストール バージョン間の競合を解決します。npm ERR! ERESOLVE が依存関係ツリーを解決できません。

まず、vue に vuex バージョンの競合をインストールするときのエラーを見てください。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR!   vue@"^2.6.14" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.0.2" from [email protected]
npm ERR! node_modules/vuex
npm ERR!   vuex@"*" 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\CRain\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\CRain\AppData\Local\npm-cache\_logs\2022-07-30T08_16_52_001Z-debug-0.log

 

npm ERR!   vue@"^2.6.14" from the root project

ここでは、現在インストールされている vue のバージョンが vue2 であることがわかります。また、現在インストールされている vue のバージョンや、vue ルート ディレクトリの下の package.json ファイル内のその他の内容も表示できます。

vue2 には vuex3 のバージョンをインストールする必要があります

npm i vuex@3 --save

vue3 には vuex4 のバージョンをインストールする必要があります

npm i vuex@4 --save

おすすめ

転載: blog.csdn.net/weixin_54570626/article/details/126074024