Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vue.js

I am a beginner with VueJs and this is my first App:

import { BootstrapVue } from 'bootstrap-vue'
import { createApp } from 'vue'
import App from './App.vue'
    
const myApp = createApp(App)
myApp.use(BootstrapVue)
myApp.mount('#app')

And when I save, nothing appears in my browser and it show this message in the Command:

warning  in ./src/main.js

"export 'default' (imported as 'Vue') was not found in 'vue'
like image 376
Noufair Younes Avatar asked Sep 06 '20 20:09

Noufair Younes


People also ask

What was not found in Vue?

To Solve export 'default' (imported as 'Vue') was not found in 'vue' Error You just need to update Vue loader to its latest version and which is 15.10. 0 You need to run the following command in your terminal: npm i [email protected] And now, Your error must be solved.

What is export default in Vue?

Using export default: You can see that we can reuse the component “TestOne” in another component named “TestTwo” by using export default. You can use export-default for creating local registration for the Vue component.


4 Answers

Bootstrap-Vue does not yet support Vue 3. So if you want to use Bootstrap-Vue you will have to stick with Vue 2 for now.

In general, most of the libraries don't support Vue 3 yet, so I would suggest waiting a bit longer before using it until the ecosystem has caught up.

Explanation

The reason this is happening is because in Vue 2, Vue provides a default export export default vue, which allows BootstrapVue to use import Vue from 'vue'.

However, in Vue 3 this has changed, and Vue does no longer provide a default export, and instead uses named exports. So when BootstrapVue uses the following line import Vue from 'vue', the error occurs.

like image 169
Hiws Avatar answered Oct 24 '22 04:10

Hiws


import * as Vue from 'vue'

this works for me

like image 42
exoticism4869 Avatar answered Oct 24 '22 02:10

exoticism4869


I was getting the warning

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

I'm using Vue 3 but the code I'm studying is Vue 2.

My code Vue 2 in main.js

import Vue from 'vue'
import App from './App.vue'
    
Vue.config.productionTip = false
    
new Vue ({
    render: h => h(App),
}).$mount('#app')

So I needed to create a Vue instance with the following code Vue 2:

export const eventBus = new Vue ()

Then I received the error code, which I resolved by correcting the code that looked like this:

import { createApp } from 'vue'
import App from './App.vue'

export const eventBus = createApp(App)

createApp(App).mount('#app')
like image 20
Nebenzahl Avatar answered Oct 24 '22 03:10

Nebenzahl


hi i am using laravel 9 mix and vue 3 here is my code app.js

// app.js
require('./bootstrap');

import { createApp } from 'vue'
import test from './components/Test.vue';

createApp({
    components: { test }
}).mount('#app')

webpack.mix.js

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js').vue();
like image 4
Gbay Frank Avatar answered Oct 24 '22 03:10

Gbay Frank