Haseeb Saeed
Haseeb Saeed

Reputation: 823

Uncaught SyntaxError: The requested module '/node_modules/.vite/vue.js?v=535663ae' does not provide an export named 'default'

I'm using a js framework known as griptape(used for blockchain). I'm getting this error when trying to use the vue router.

import Vue from "vue"; //Error **does not provide an export named 'default'**
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
  },
];

 const router = new VueRouter({
  routes,
});
export default router;

while my vue.d.ts file looks like this

import { CompilerOptions } from '@vue/compiler-dom';
import { RenderFunction } from '@vue/runtime-dom';

export declare function compile(template: string | HTMLElement, options?: CompilerOptions): RenderFunction;

export * from "@vue/runtime-dom";

export { }

router.d.ts file look like this enter image description here

Upvotes: 6

Views: 16453

Answers (2)

fsarter
fsarter

Reputation: 942

I think you are using Vue 3. You should check your vue-router version. If you just run npm i vue-router now, the version should be "^3.5.3". Try to use npm i vue-router@next to install newer version.

Then export router like this:

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

const routes = [
    {
        path:'/',
        name:"Home",
        component:()=>import('./pages/Home.vue')
    }
    ,
    {
        path:'/about',
        name:"About",
        component:()=>import('./pages/About.vue')
    }
]

const router = createRouter({
    history:createWebHistory(),
    routes
})

export default router

Upvotes: 8

phn
phn

Reputation: 105

You technically didn't ask a question I will try to explain the error. Your error states what you try to do, importing a default export from the module 'vue' which doesn't exist.

// some ts file
import Vue from "vue";

// the module
export default {}

If there should be a named export called 'Vue' you should write it as follows: import { Vue } from 'vue'

references:

Upvotes: -2

Related Questions