3

I recently upgraded to vue3 using vue-next and when I run yarn serve I get some warnings.

import Vue from 'vue'; causes this warning "export" 'Vue' was not found in 'vue'.

import { createApp, h } from 'vue' works fine!

package.json

{
  ...
  "dependencies": {
    ...,
    "vue": "^3.0.0-beta.1"
  }
}

Similar threads:

3 Answers 3

2

You say you've recently upgraded to Vue 3. The import Vue from 'vue' syntax is no longer supported, since Vue has been restructured to support tree-shaking.

Instead of trying to use Vue.function, simply import { function } from 'vue' and use it directly.

This is documented in the migration guide here: https://v3-migration.vuejs.org/breaking-changes/global-api-treeshaking.html#global-api-treeshaking

I'd recommend giving the rest of the migration guide (at least the breaking changes) a read-through as well. It's very handy.

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

Comments

0

Have you tried:

if (process.client) {
  import Vue from 'vue'
}

For more clarification https://nuxtjs.org/faq/window-document-undefined

Comments

0

try importing with this.

if (process.client) {
  import vue from 'vue'
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.