Reputation: 45
Im a newbie vuejs dev and im trying to use vuex for state management but encounter an error. Here is the code:
**main.js file**
import { createApp } from 'vue';
import router from './router';
import store from './store/index';
import App from './App';
import vuetify from './plugins/vuetify';
const app = createApp(App);
app.use(router);
app.use(store);
app.use(vuetify);
app.mount('#app');
**error**
WARNING Compiled with 4 warnings
warning in ./src/main.js
"export 'createApp' was not found in 'vue'
warning in ./node_modules/vuex/dist/vuex.esm-browser.js
"export 'inject' was not found in 'vue'
warning in ./node_modules/vuex/dist/vuex.esm-browser.js
"export 'reactive' was not found in 'vue'
warning in ./node_modules/vuex/dist/vuex.esm-browser.js
"export 'watch' was not found in 'vue'
Upvotes: 2
Views: 11815
Reputation: 138196
The errors (and the vuejs2 you've added to the question) seem to indicate that you're running Vue 2, but your code is actually using Vue 3's API.
The simplest solution that would require the least change is to install Vue 3 in your project:
npm install --save vue@3
Upvotes: 3
Reputation: 81
I think, you need to use like that way:
const app = Vue.createApp({/* options */})
or
import { createApp } from "vue";
const app = createApp({
// root instance definition
});
And main.js is not suitable for that definition, I guess.
Reference from Vue document
Upvotes: 0