I just started using vite with vue.
When i'm trying to use vue-router I get the error:
SyntaxError: The requested module '/node_modules/.vite/vue-router/dist/vue-router.esm.js?v=4830dca4' does not provide an export named 'createRouter
My router/index.js looks like this:
import {
createWebHistory,
createRouter
} from "vue-router";
import Services from "../views/Services.vue";
import Costumers from "../views/Costumers.vue";
const history = createWebHistory();
const routes = [
{
path: "/",
component: Services
},
{
path: "/costumers",
component: Costumers
},
];
const router = createRouter({
history,
routes
});
export default router;
My main.js looks like this:
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
import router from './router'
createApp(App).use(router).mount('#app')
My package.json looks like this:
{
"name": "frontend",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"vue": "^3.0.5",
"vue-router": "^3.4.9"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.0.4",
"@vue/compiler-sfc": "^3.0.5",
"autoprefixer": "^10.2.3",
"postcss": "^8.2.4",
"tailwindcss": "^2.0.2",
"vite": "^2.0.0-beta.12"
}
}
Anyone knows how to export the route?
question from:
https://stackoverflow.com/questions/65858930/does-not-provide-an-export-named-createrouter-vue-3-vite-and-vue-router 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…