posva / unplugin-vue-router

Next Generation file based typed routing for Vue Router
https://uvr.esm.is
MIT License
1.47k stars 67 forks source link

Does not provide an export named 'routes' on fresh install of vue #426

Closed andyjamesn closed 1 month ago

andyjamesn commented 1 month ago

I had this issue on an existing project. So decided to try on a fresh install of vue with npm create vue@latest.

I added vue router and then replaced the router as per the docs with

import { createRouter, createWebHistory } from 'vue-router/auto'
import { routes } from 'vue-router/auto-routes'
"unplugin-vue-router": "^0.10.0",
 "vue": "^3.4.29",
 "vue-router": "^4.4.0"

But I get the same error:

SyntaxError: The requested module '/node_modules/.vite/deps/vue-router_auto-routes.js?v=81ebd606' does not provide an export named 'routes' (at index.ts:2:10)

andyjamesn commented 1 month ago

I was missing the vite config.

I hadnt seen the documentation link at the bottom of the readme page in github.

VueRouter({
      logs: true,
      routesFolder: [
        {
          src: 'src/pages',
        },
      ],
    }),

After this I ran dev again and I see it created the routes and everything works fine now.