Uncaught TypeError: src.Router is not a constructor
See original GitHub issueHi!
I’m just trying to make it work with a simple code, but I receive this error when running on Windows 10 x64 - Chrome 87.0.4280.88 64 bits.
My Code:
main.svelte
import App from './App.svelte';
const app = new App({ target: document.body });
export default app;
App.svelte
<script>
import { Router } from 'svelte-router-spa'
import { routes } from './routes'
</script>
<Router {routes} />
routes.js
import Dashboard from './views/dashboard.svelte'
const routes = [
{ name: '/', component: Dashboard }
]
export { routes }
views/dashboard.svelte
<div>
<h1>Dashboard</h1>
</div>
I run using rollup -c -w
and sirv public -s
, both give me same error.
I’m lost. Can you help me?
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
vue.js - Uncaught TypeError: VueRouter is not a constructor
I tried the solution provided by another post on SO, by adding the following to the top of my app.js file: import VueRouter...
Read more >TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >Is not a constructor - Auth0 Community
I am getting “is not a constructor” when trying to implement auth0 ... Uncaught TypeError: WEBPACK_IMPORTED_MODULE_6__auth_Auth.a is not a ...
Read more >Getting Uncaught TypeError: Vue is not a constructor while ...
Getting Uncaught TypeError: Vue is not a constructor while running the Tailwind Traders project which is mentioned in the "Build Serverless ...
Read more >symfony vue.js:4 uncaught typeerror - You.com
Uncaught TypeError : vue__WEBPACK_IMPORTED_MODULE_4__.default is not a constructor ... Tried using vue-router for the first time with separate route.js file ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I got same error with webpack bundling. I could solve it by using
<Route.default
and<Router.default
from https://github.com/jorgegorka/svelte-router/issues/90#issuecomment-753722214 which seems quite strange to me but at least it’s working for me.Hello i hope that answers to this issue #91 can helps you