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.

Uncaught TypeError: src.Router is not a constructor

See original GitHub issue

Hi!

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.

image

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:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
robertfauskcommented, Jan 20, 2021

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.

1reaction
ffvporcommented, Dec 24, 2020

Hello i hope that answers to this issue #91 can helps you

Read more comments on GitHub >

github_iconTop 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 >

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