Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am new with this vue and I got this error when I try to run (npm run serve):

***WARNING Compiled with 4 warnings
warning in ./src/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
warning in ./src/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
warning in ./src/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
warning in ./src/router/index.js
"export 'default' (imported as 'Vue') was not found in 'vue'

App running at:

  • Local: http://localhost:8080/
  • Network: http://10.2.220.30:8080/***
  • index.js

    import Vue from "vue";
    import VueRouter from "vue-router";
    import Home from "../views/Home.vue";
    Vue.use(VueRouter);
    const routes = [{
            path: "/home",
            name: "home",
            component: Home,
            meta: {
                requiresAuth: true
            path: "/",
            name: "login",
            component: () =>
                import ("../views/login.vue")
            path: "/register",
            name: "register",
            component: () =>
                import ("../views/register.vue")
    const router = new VueRouter({
        mode: "history",
        base: process.env.BASE_URL,
        routes
    router.beforeEach((to, from, next) => {
        if (to.matched.some(record => record.meta.requiresAuth)) {
            if (localStorage.getItem("jwt") == null) {
                next({
                    path: "/"
            } else {
                next();
        } else {
            next();
    export default router;
    

    main.js

    import Vue from "vue";
    import App from "./App.vue";
    import router from "./router";
    import axios from "axios";
    import "bootstrap/dist/css/bootstrap.css";
    const base = axios.create({
        baseURL: "http://localhost:4000"
    Vue.prototype.$http = base;
    Vue.config.productionTip = false;
    new Vue({
        router,
        render: h => h(App)
    }).$mount("#app");
                    Did you install Vue 2 or Vue 3? Vue recently released 3.0.0, and it has a different syntax for initializing Vue. Which is why you might have issues with the syntax above.
    – Hiws
                    Sep 24, 2020 at 6:32
                    At first it works fine when I run npm run serve..but as I go through in this project I got this error, that's why I install vue using npm but then again I got the same error.
    – cypher
                    Sep 24, 2020 at 7:02
    

    When you upgrade to vue v3 should upgrade vue-router to 'vue-router/next' Offical website and use this code instead to import the function

    import { createRouter, createWebHistory } from 'vue-router'
    

    and remove

    Vue.use(VueRouter);
    

    Type these commands in the project terminal

    npm uninstall vue-router --legacy-peer-deps
    npm install --save vue-router@3
    

    It worked in my case the issue was due to vue-router version

    https://blog.csdn.net/cxl1191628698/article/details/127352186

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.