DEV Community

kevinadhiguna
kevinadhiguna

Posted on

Could not resolve peer dependency vuex@"^3.0 || ^4.0" with Vuex 4.0.0-rc.2 installed

Background

This post was written since robinvdvleuten/vuex-persistedstate has been archived on February 2022.

However, the issue is still open...


Problem

The error message was shown when I was trying to install dependencies with npm install.

Here was my package.json :

...
"dependencies": {
    ...
    "nuxt": "^2.15.8",
    "vue": "^2.6.14",
    "vuex-persistedstate": "^4.1.0",
    ...
},
...
Enter fullscreen mode Exit fullscreen mode

The log of npm install was :

$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: frontend-v2-nuxt2@1.0.0
npm ERR! Found: vue@2.6.14
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 vuex@4.0.2
npm ERR! node_modules/vuex
npm ERR!   peer vuex@"^3.0 || ^4.0.0-rc" from vuex-persistedstate@4.1.0
npm ERR!   node_modules/vuex-persistedstate
npm ERR!     vuex-persistedstate@"^4.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 /home/kevin/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kevin/.npm/_logs/2022-02-28T07_34_01_560Z-debug.log
Enter fullscreen mode Exit fullscreen mode

Solution

I noticed that the package vuex-persistedstate@"^4.1.0" required vuex@"^3.0 || ^4.0.0-rc". Therefore, I added vuex package :

npm install vuex@^3.0
Enter fullscreen mode Exit fullscreen mode

After that, try installing dependencies with :

npm install
Enter fullscreen mode Exit fullscreen mode

The error was gone this time.

package.json after being updated :

...
"dependencies": {
    ...
    "nuxt": "^2.15.8",
    "vue": "^2.6.14",
    "vuex": "^3.6.2",
    "vuex-persistedstate": "^4.1.0",
    ...
},
...
Enter fullscreen mode Exit fullscreen mode

It is clear that vuex as a required package for vuex-persistedstate has been added.

Top comments (0)