posva/unplugin-vue-router

Cannot find module 'vue-router/auto' or its corresponding type declarations

Closed this issue ยท 17 comments

With version 0.8.x the typings for vue-router/auto disappeared. They don't seem to be part of the unplugin-vue-router/client that gets added to tsconfig, nor are they present in the typed-router.d.ts anymore

Screenshot 2024-02-22 at 16 04 53

which leands to

Screenshot 2024-02-22 at 16 04 11

repo: https://github.com/Ribeiro-Tiago/repro-repo

I cannot reproduce, I get the same issue as #322. You might have hit a cache issue?

:(

what would be caching this do you think ? I created a new project for that reproducible

Thatโ€™s weird but I canโ€™t reproduce it

Can you try with the new version? I still can't reproduce it

I can reproduce of typed-router.d.ts missing the /auto the module after upgrading to 0.8. This was on a project using create vuetify. Steps to reproduce:

  1. npm create vuetify@latest - At time of writing, this comes with unplugin-vue-router 0.7
  2. npm run dev - see that vue-router/auto is in d.ts
  3. update package.json to 0.8
  4. npm run dev - see that vue-router/auto has disappeared

Only the auto-routes module renamed in 0.8 is generated.

@juw177 there is a client file to add (instructions in changelog)

the template will need to be updated alongside this package

Thanks @posva , yes, I have added "types": ["unplugin-vue-router/client"], to tsconfig but still didn't work. Strangely, even in the example on the setup page, there is no module called vue-router/auto:

image

Still nothing with 0.8.4. Not sure if it matters, but I'm using yarn v4 pnp as package manager

I have the same problem have to go back to 7.0.

@Ribeiro-Tiago #118
@juw177 the module declaration was moved to unplugin-vue-router/client, that's why it's not there.
I will be happy to take a look if anybody can provide a reproduction (without yarn pnp ofc)

Setting moduleResolution: Bundler (+ changes mentioned in changelog) fix it for the vuetify template. I added that to the docs: 76f9392

Thanks @posva , that worked. As for @Ribeiro-Tiago , I think the problem with your confis is you have defined types twice so overwrote the other.

Thanks It was the "moduleResolution": "Bundler" that fix it.

@posva indeed, using "moduleResolution": "Bundler", does the trick

It does break typing for vuex imports, Could not find a declaration file for module 'vuex'. but this result could not be resolved when respecting package.json "exports". The 'vuex' library may need to update its package.json or typings, but this seems to be a good enough workaround, and I'll be replacing vuex with pina soon โ„ข๏ธ so doesn't matter much :p

I think Vuex types need to be fixed ๐Ÿ˜…

For folks who ran into this even with moduleResolution: Bundler โ€” try bumping up vue-router from 4.1 to 4.3. That fixed it for me!

For folks who ran into this even with moduleResolution: Bundler โ€” try bumping up vue-router from 4.1 to 4.3. That fixed it for me!

This (and none of the previous solutions in this page) was what made it work for me, thank you!