Getting "export 'createStore' was not found in 'vuex' warning

6.3k Views Asked by At

I'm new to all these and now learning Vue. I have install Vuex, use export default, and import it but still getting this error =>

WARNING Compiled with 1 warnings
warning in ./src/store/index.js "export 'createStore' was not found in 'vuex'

The index.js store file

import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

import coachesModule from './modules/coaches/index.js';

const store = new Vuex.Store({
  modules: {
    coaches: coachesModule
  }
});

export default store;


The package.json file

{
  "name": "vue-first-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-rc.5",
    "vuex": "^3.5.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0-0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^7.0.0-0"
  }
}

After uninstalling Vue using

npm uninstall -g @vue/cli

and reinstall Vue Using

npm install -g @vue/cli@latest 

npm i vue vue-router -S
npm install 

now still im getting :

 INFO  Starting development server...
98% after emitting CopyPlugin

 WARNING  Compiled with 1 warnings                                             3:56:20 PM

 warning  in ./src/store/index.js

"export 'default' (imported as 'Vue') was not found in 'vue'

Anyone can help me?

3

There are 3 best solutions below

0
On BEST ANSWER

Upd. You use vue3 and vuex3, but you should use vuex4.


Can you try to use

const store = new Vuex.Store({ 
    // options
})

instead of

const store = createStore({ 
    // options
})

?

According to this docs https://vuex.vuejs.org/guide/#the-simplest-store .

0
On

createStore is Vuex 4 syntax, since you're using vuex 3 you should do :

import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)

import coachesModule from './modules/coaches/index.js';

const store = new Vuex.Store({
  modules: {
    coaches: coachesModule
  }
});

export default store;
0
On

I had the same problem using Quasar as a UI framework and got it solved by running

yarn add vuex@next

or if you are using npm

npm install --save vuex@next

then rebuilding the project got everything running again.

more details in this ref: https://www.codegrepper.com/code-examples/whatever/%22export+%27createStore%27+was+not+found+in+%27vuex%27

what this did in the background was changing the "vuex":"^3.6.2" to "vuex": "^4.0.2"