question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

export 'Route' was not found in 'vue-router'

See original GitHub issue

Version

3.0.0-beta.15

Reproduction link

https://github.com/doppelreim/vue-test-app/tree/test-import-route

Steps to reproduce

Run npm run serve

What is expected?

The app should compile without warnings.

What is actually happening?

It does not compile without warnings.

The output says:

 WARNING  Compiled with 4 warnings                                                                                                            12:38:25

 warning  in ./src/components/HelloWorld.vue?vue&type=script&lang=ts

"export 'Route' was not found in 'vue-router'

 warning  in ./src/components/HelloWorld.vue?vue&type=script&lang=ts

"export 'Route' was not found in 'vue-router'

 warning  in ./src/components/HelloWorld.vue?vue&type=script&lang=ts

"export 'Route' was not found in 'vue-router'

 warning  in ./src/components/HelloWorld.vue?vue&type=script&lang=ts

"export 'Route' was not found in 'vue-router'

The change that introduces the warnigns can be seen here: https://github.com/doppelreim/vue-test-app/commit/af036724ecbe53853ce10707796c82213ae07a43

I want to add a Watcher on $route. The parameters of the function (newRoute and oldRoute) should be typed. I assume Route is the correct type.

I checked out /node_modules/vue-router/types/index.d.ts and there Route does get exported, as far as I can tell.

If I use Route inside of the function-body, like this:

const r: Route = {
      path: '',
      hash: '',
      query: {},
      params: {},
      fullPath: '',
      matched: [],
    };

then it does not throw errors. And if i leave out some of the required attributes, then the compiler rightfully complains. So I assume the export/import does work here.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
eyedeancommented, May 17, 2021

As of Typescript 3.8 (which is older than the discussion in this ticket), with type-only import/exports, one can use import type { Router } instead of import { Router }.

That fixed these warnings for me. 😃

I guess it could fix a similar issue in other cases:

1reaction
lgarczyncommented, Jan 22, 2022

It is possible to ask typescript-eslint to fix all imports of types to the import type syntax.

You simply need to use@typescript-eslint/consistent-type-import with { prefer: 'import-types'}

Read more comments on GitHub >

github_iconTop Results From Across the Web

export 'default' (imported as Vue ) was not found in 'vue'
When you upgrade to vue v3 should upgrade vue-router to 'vue-router/next' ... import { createRouter, createWebHistory } from 'vue-router'.
Read more >
Im using VueJs and Laravel8 and i want to import vue-router ...
js :"export 'VueRouter' was not found in 'vue-router'. Im using VueJs and Laravel8 and i want to import vue-router. Her is my app.js...
Read more >
Migrating from Vue 2 - Vue Router
Reason: Vue Router doesn't use path-to-regexp anymore, instead it implements its own parsing system that allows route ranking and enables dynamic routing. Since ......
Read more >
How to use vue-router? - CodinGame
Routing is the way to manage the components in a Single Page Applications. ... Home.vue <template> <h1>Home</h1> </template> <script> export default ...
Read more >
WARN export 'default' (imported as 'Vue') was not found in 'vue'
Hello Friends! , today while I was working on How to setup a Vue JS v3 project from scratch (without Vue CLI) (Including...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found