The solution to vue3 being unable to install vuex: 1. Check the error message; 2. Use version 4 of vuex in Vue3; 3. Enter the "npm install vuex@next --save" command to install it.
#The operating environment of this tutorial: Windows 10 system, Vue version 3, Dell G3 computer.
What should I do if vue3 cannot install vuex?
vue3 error when installing vuex: Could not resolve dependency npm ERR peer vue@“^2.0.0“ from vuex@3.6.2
Solution:
Enter npm install vuex@next --save
, and the installation will be successful
Related introduction:
On February 7, 2022, vue3 became the default version. And when vue3 became the default version, vuex was also updated to version 4. That is, if you execute npm i vuex now, vuex4 will be installed.
The 4th version of vuex can only be used in vue3. If we insist on using version 4 of vuex in a vue2 project, an error will appear.
The matching rules are as follows:
(1) In Vue2, version 3 of vuex must be used;
(2) In Vue3, version 4 of vuex must be used.
Recommended learning: "vue.js video tutorial"
The above is the detailed content of What should I do if vue3 cannot install vuex?. For more information, please follow other related articles on the PHP Chinese website!