I'm trying to use Vuex with Vue 3. Here is my code in main.js:
import { createApp } from 'vue';
import App from './App.vue';
import Vuex from 'vuex';
const app = createApp(App);
app.use(Vuex);
const store = new Vuex.Store({
state: {
counter: 0
}
});
app.store(store);
app.mount('#app');
When trying this, I get the following error:
Uncaught TypeError: Vue is not a constructor
I have tried using the syntax recommended in the official Vuex docs but this does not work either. Does anyone know how to fix this?
package.jsonis not a reliable way to check the exact installed version. That said, it looks like you have Vuex 3 when you need Vuex 4. See github.com/vuejs/vue-next#vuex