65

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'
10
  • 1
    are you using vue 3? Commented Sep 6, 2020 at 20:27
  • 1
    Yes Vue Cli3 , it worked fine the first time but when i import the BootstrapVue the command showed the message above Commented Sep 6, 2020 at 21:04
  • please share your package.json content Commented Sep 6, 2020 at 21:08
  • "dependencies": { "bootstrap": "^4.5.2", "bootstrap-vue": "^2.16.0", "core-js": "^3.6.5", "vue": "^3.0.0-rc.10", "vue-loader-v16": "npm:vue-loader@^16.0.0-alpha.3", "vue-property-decorator": "^9.0.0" }, "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", "bootstrap": "^4.3.1", "eslint": "^6.7.2", "eslint-plugin-vue": "^7.0.0-0", }, Commented Sep 6, 2020 at 21:19
  • 2
    you're installing the vue version 3 which is in beta version and using a library (i mean bootstrap-vue) which is built using vue 2, if you don't have much progress in your project i could suggest the right setup Commented Sep 6, 2020 at 21:30

11 Answers 11

76

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.

Sign up to request clarification or add additional context in comments.

9 Comments

i came across this problem using vue2
Still the same. :( 2021-07-19
Doesn't really explain how to fix it
@ak22 So if you want to use Bootstrap-Vue you will have to stick with Vue 2 for now., not sure how that isn't a solution?
Frankly all I did was create a new project (not bootstrap but quasar) and I copied over a .js file from a previous project used "import Vue from 'vue'". My package.json has vue at 2.6.12 but still get this error. So, not sure what I need to do. Thanks for your reply.
|
55

import * as Vue from 'vue'

this works for me

7 Comments

lol. Why is this not documented anywhere? (thank you)
haha, who knows, these small things always confuse people
Can you please extend your answer? Some more code e.g. your working code in main.js can help more people I think.
good, I will pay attention to it!
After i did that i got this error export 'component' (imported as 'Vue') was not found in 'vue'
|
20

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')

Comments

6

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();

Comments

3

in my case, I use webpack and vue2.

I use vue-loader to handle .vue file . I found I installed vue-loader v17 which requires vue3, so I uninstall it and npm i vue-loader@15

Comments

3

In my case, this looks like it was caused by some sort of corrupt node module somewhere. I solved the problem by running

rm -rf node_modules/

In my project root directory. This deletes your node_modules folder. Then I reran

yarn install

or

npm install

and the problem was fixed. Hope this helps someone else. Also, many have noted the differences between vue 3 and vue 2 dependencies, I'm not sure those are still relevant in 2022.

Comments

2

None of the current responses fixed the issue for me though mine was a little different; I control the component that was failing and I know it was made with Vue3.

In case someone hits this issue but with a component they control, it COULD be that you removed the setup attribute from your components <script> tag.

So changing

<script lang="ts">

to

<script setup lang="ts">

fixed it for me

Comments

1

On Vue 3 applications you have to use the following connection Vuex store

store.js

import { createStore } from "vuex";
import axios from "axios";

export default createStore({
    state: {
    },
    mutations: {
    },
    actions: {
    }
})

main.js

import store from '@/store';
...
app.use(store);

Comments

0

In my case it was the wrong resolve.alias directive in webpack.config.js, which set 'vue' to 'vue/dist/vue.js' instead of 'vue/dist/vue.esm.js';

Comments

0

If you're using Vuex, running:

npm remove vuex

npm i vuex@3

should fix this problem.

2 Comments

You can't use vuex@3 unless you use vue 3 though?
@lloydcox no, version 3 in vuex isn't related to Vue 3.
-1
const Vue = require('vue')
const AppImport = Vue.createApp("dev-axios");
import axios from 'axios';
import VueAxios from 'vue-axios';
AppImport.use(VueAxios,axios);

1 Comment

Please add some explanations.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.