Search code examples
vue.jsvuexnpm-installvuex4

i can't install vuex by npm


$ npm install vuex --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR!   dev vue@"^2.6.12" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.2.0" 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\Fatima Hafeez\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\Fatima Hafeez\AppData\Local\npm-cache\_logs\2023-03-05T11_51_33_122Z-debug-0.log

How i solve this error?


Solution

  • It looks like you are using Vue 2 and you are trying to install VueX 4 but they are not compatible together.

    VueX 4 is for Vue 3
    VueX 3 is for Vue 2

    You need to specify that you don't want the latest version but the V3 when using npm install: npm install vuex@3