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.

URL is not a constructor

See original GitHub issue

I’m trying to work with this library. When I try to use it in a new URL(url) way, it says: Type Error: URL is not a constructor

When I try to use it as function, it says: Type Error: Failed to construct ‘URL’. Please use the ‘new’ operator; this constructor cannot be called as a function.

I’m using node v6.10.3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
domeniccommented, Jul 19, 2017

Yes. But it’s not what @herodrigues or, probably, you, are doing.

1reaction
stevenvachoncommented, Jul 19, 2017
const {URL} = require('whatwg-url');

new URL('http://host/');
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: URL is not a constructor using WHATWG ...
I faced the same issue, then I looked into the url module and found a solution. For Node V6 use, const URL =...
Read more >
TypeError: URL is not a constructor :( · Issue #105 - GitHub
In the third file url.js (where the basic logic for the url library is described) the URL class is missing. And this is...
Read more >
o.URL is not a constructor - The Observable Forum
o.URL is not a constructor · load your notebook, open dev tools · enable “pause on exceptions” and “pause on caught exceptions” (important, ......
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 >
TypeError: "X" is not a constructor in JavaScript [Solved]
To solve the "TypeError: 'X' is not a constructor" in JavaScript, make sure to only use the new operator on valid constructors, e.g....
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