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.

Class constructor SvelteComponent cannot be invoked without 'new'

See original GitHub issue

🐛 Bug Report

Hi, got some strange error with a basic “Hello world” app.

Class constructor SvelteComponent cannot be invoked without 'new', pointing my app.js

🎛 Configuration (.svelterc, package.json, cli command)

Nothing special.

💻 Code Sample

Everything’s in the repo, but the code is quite simple :

import App from "./components/app.svelte";

const root = new App({
    target: document.querySelector("#root"),
    props: {},

export default root;

and the app.svelte is:

	let name = 'world';

<h1>Hello {name.toUpperCase()}!</h1>

🌍 Your Environment

Svelte version ^3.1.0, Parcel version ^1.12.3, plugin version 3.0.0

Thanks in advance!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:43
  • Comments:30 (8 by maintainers)

github_iconTop GitHub Comments

samuelgozicommented, Sep 16, 2019

This is not an issue specific to this plugin, this is an issue that is caused due to some design decisions made in Parcel. Specifically(as mentioned above) the decision not to transpile packages in the node_modules folder. You can see the issue in their repository here:

I’m subscribed to that issue, and to other issues regarding HMR, and will update this plugin when possible. Until then there is nothing we can do… EDIT: Updated the link to the issue, accidentally linked a different one.

GeordiePcommented, Apr 26, 2019

I have the same issue.

Adding the following to package.json (as recommended by this comment) get things compiling and displaying on the page:

  "browserslist": [
    "last 1 chrome versions"

However, HMR throws an error (browser console):

proxy.js:62 Uncaught TypeError: Cannot read property 'apply' of undefined
    at proxyComponent.self.<computed> [as get] (proxy.js:62)
    at proxyComponent._rerender (proxy.js:185)
    at hot-api.js:43
    at Array.forEach (<anonymous>)
    at reload (hot-api.js:43)
    at Object.eval (eval at hmrApply (hmr-runtime.js:153), <anonymous>:104:11)
    at newRequire (main.1f19ae8e.js:47)
    at hmrAcceptRun (hmr-runtime.js:203)
    at hmr-runtime.js:60
    at Array.forEach (<anonymous>)

Manually refreshing the page works fine, so we can provide the --no-hmr CLI option to Parcel and get rid of that issue, but obviously this isn’t ideal as we no longer have HMR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class constructor SvelteComponent cannot be invoked ...
When I build with webback, I will report an error:Class constructor SvelteComponent cannot be invoked without 'new'
Read more >
How to resolve 'class constructor cannot be invoked without ...
This needs to be compatible with IE11 while using ES6 syntax. I get. Class constructor I cannot be invoked without 'new'. The pertinent...
Read more >
Class constructor cn cannot be invoked without 'new'
Hi! We are using the plugin and is awesome! We noticed that when triyng to login with the address we get this...
Read more >
Class constructor SvelteComponent cannot be invoked without 'new '
Read more >
yrv - npm Package Health Analysis | Snyk
When yrv adds a new route, it'll use any given key from its props — once routes are ... Class constructor SvelteComponent cannot...
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 Hashnode Post

No results found