I am not able to use vuex ("vuex": "^2.2.1") in my app, I have followed all the instructions and installed and created store file but its giving me this error
vuex.esm.js?edaa:
61 Uncaught TypeError: store.subscribe is not a function
at devtoolPlugin (eval at <anonymous> (http://localhost:8080/app.js:1245:1), <anonymous>:61:9)
at eval (eval at <anonymous> (http://localhost:8080/app.js:1245:1), <anonymous>:292:68)
at Array.forEach (native)
at Object.Store (eval at <anonymous> (http://localhost:8080/app.js:1245:1), <anonymous>:292:33)
at eval (eval at <anonymous> (http://localhost:8080/app.js:992:1), <anonymous>:43:111)
at Object.<anonymous> (http://localhost:8080/app.js:992:1)
at __webpack_require__ (http://localhost:8080/app.js:660:30)
at fn (http://localhost:8080/app.js:84:20)
at eval (eval at <anonymous> (http://localhost:8080/app.js:839:1), <anonymous>:9:71)
at Object.<anonymous> (http://localhost:8080/app.js:839:1)
devtoolPlugin @ vuex.esm.js?edaa:61
(anonymous) @ vuex.esm.js?edaa:292
Store @ vuex.esm.js?edaa:292
(anonymous) @ store.js?adc6:43
(anonymous) @ app.js:992
__webpack_require__ @ app.js:660
fn @ app.js:84
(anonymous) @ main.js?1c90:10
(anonymous) @ app.js:839
__webpack_require__ @ app.js:660
fn @ app.js:84
(anonymous) @ app.js:1282
__webpack_require__ @ app.js:660
(anonymous) @ app.js:709
(anonymous) @ app.js:712
backend.js:1 [vue-devtools] Ready. Detected Vue v2.1.10
this is my store file and that's how I am importing it
store/store.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default Vuex.Store({
state: {
counter: 0
}
})
in my main.js
import store from './store/store'
new Vue({
el: '#app',
store,
...
}
please help whats wrong, I have used vue cli with webpack template vue init webpack myapp to generate it.
Most helpful comment
Replace
export default Vuex.Storewithexport default new Vuex.Store.Vuex.Storeis not a normal function but a constructor.Please use our forum or gitter to ask usage/support questions in the future.