I am developing an application in Express and Vue js I'm getting this:
Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/vue.js?v=460a75c2' does not provide an export named 'Vue' (at main.js?t=1667997788986:1:9)
App.vue file :
import {Vue, createApp } from 'vue'
import App from './App.vue'
import './assets/main.css'
import axios from 'axios'
import vueAxios from 'vue-axios'
Vue.use(axios, vueAxios)
createApp(App).mount('#app')
My main.js file is :
<script>
export default {
data(){
return{
dataResponse: [],
}
},
methods: {
async getDataResponse(){
const res = await axios.get(`${this.baseUrl}/catalog/home`)
console.log(response)
}
},
created(){
this.getDataResponse()
}
}
</script>
<template>
<h1>Welcome</h1>
</template>
CodePudding user response:
If your are using Vue 2.7 and 3.x, do you mind if try import { createApp } from 'vue'
, and then use createApp(App).use(axios).use(vueAxios).mount('#app')
? It should be works because of import nature.
Another alternative:
import { createApp } from 'vue'
import App from './App.vue'
import './assets/main.css'
import axios from 'axios'
import vueAxios from 'vue-axios'
const app = createApp(App)
app.use(axios)
app.use(vueAxios)
app.mount('#app')
CodePudding user response:
You didn't write which version of Vue you are using, but based on the fact that you are using createApp
it looks like you are using Vue 3.
In that case, the error is correct -- there is no export called Vue in the module vue
. Vue 3 removed the default export, so you can't write import Vue from 'vue'
anymore, and there is no export named Vue
in the package, so import { Vue } from 'vue'
is not valid either.
You're probably trying to follow an old tutorial about installing Vue plugins. In Vue 3, instead of writing Vue.use(plugin)
, you would write createApp().use(plugin)
instead.