Search code examples
vue.jsvuexvuex4

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


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?


Solution

  • 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 .