vue.jsvuejs3nuxt.jsvuexvuex4

vue.reactive is not a function


I tried to migrate a vue project to a nuxt project. The problem is using store/index.js file.

I copied the origin file into store folder and this error occurs. I could't find the reason. enter image description here

store/index.js

import { createStore } from "vuex";

export default createStore({
  state: {},
  mutations: {},
  actions: {},
  modules: {},
});

Solution

  • createStore is a method of Vuex4, which is aimed towards Vue3.
    If you want to use Vuex4, you'll need to use Nuxt3 (which is as of today, not 100% production-ready overall but may still be okay for a smaller project IMO).