search

Home  >  Q&A  >  body text

How to add Vuex 3 for Vue 2.7?

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

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

I need to use Vuex. For this environment I have to use Vuex 3. So I did what the documentation said: yarn add vuex. But this always results in installing vuex 4:

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

But this will cause various problems, because vuex 4 only works with Vue 3.

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

How do I install Vuex 3 for Vue 2.7 in my Nuxt project? What did I miss?

P粉222320176P粉222320176259 days ago1545

reply all(1)I'll reply

  • P粉674999420

    P粉6749994202024-04-06 00:19:26

    yarn add package-name Installs the "latest" version of the package. yarn add package-name@1.2.3 Installed a specific version of a package from the registry.

    Try yarn add vuex@3

    reply
    0
  • Cancelreply