Vue CLI 4.5.*: "export 'default' (imported as 'Vue') was not found in 'vue'

7.4k Views Asked by At

While working with Vue CLI 4.5.x, I tried the following code:

import Vue from "vue"
import App from './App.vue'

new Vue({
    el: "#app",
    render: h=> h(App)
})

But unfortunately, it gave the following warnings:

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

What I can conclude from this, is that Vue CLI 4.5.x has stopped this way of creating an application where you first create a Vue instance.

To initialize the main application, the official way is as follows:

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

createApp(App).mount('#app')

I'm not sure if my conclusion is correct or not. It would be a great help if somebody would concrete my conclusion, as so far I have not found any proof of that in official documentation of vue.

Moreover, the later code comes baked with Vue CLI 4.5.* application instance, while former code is true when using the CDN.

1

There are 1 best solutions below

5
On BEST ANSWER

You've installed vue 3 using vue-cli 4 and this version has this new global api for creating new app :

import { createApp } from 'vue'

const app = createApp({})

You're still able to create apps using vue 2 based on vue cli 4 but you should indicate the version when you launch new project.