Search code examples
vue.jsvuejs2nuxt.jsvuex

How to add Vuex 3 for Vue 2,7?


When I run: yarn create nuxt-app I see in package.json that I have:

"dependencies": {
   "nuxt": "^2.15.8",
   "vue": "^2.7.10",
},

I need to use Vuex. For this environment, I must use Vuex 3. So I do what the documentation says: yarn add vuex. But this always leads to the installation of vuex 4:

"dependencies": {
   "nuxt": "^2.15.8",
   "vue": "^2.7.10",
   "vuex": "^4.1.0"
},

But this leads to various issues because vuex 4 is suitable for Vue 3 only.

The result of running yarn add vuex is the same as running yarn add vuex@next --save.

How to install vuex 3 for Vue 2.7 in my Nuxt project ? What am I missing ?


Solution

  • yarn add package-name installs the “latest” version of the package. yarn add package-name@1.2.3 installs a specific version of a package from the registry.

    Try yarn add vuex@3