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.

JSDOM is not a constructor

See original GitHub issue

Basic info:

  • Node.js version: 10
  • jsdom version: 13.0.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const dom = new JSDOM(html);

I have this warning:
`
index.js?bed3:153 ./node_modules/jsdom/lib/jsdom/utils.js
216:21-40 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/jsdom/lib/jsdom/utils.js
 @ ./node_modules/jsdom/lib/jsdom.js
 @ ./src/components/IStore.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
`


I am not sure how to fix it, it's doesn't show me what dependency i need to update or install.  

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
LinusLingcommented, Jun 17, 2020

After the debug, following code can be normal to use jsdom 🤩

const jsdom = require("./node_modules/jsdom");
const { window } = new jsdom.JSDOM('<body></body>');

However, I still can’t imagine why the basic usage of jsdom is not work 🤷‍♂️

0reactions
DespertaWebcommented, Jun 22, 2020

I’ve ended up using http://pdfmake.org/

It works just fine, but you have to parse everything into the expected format thoug.

Plus be aware: is Heavy as hell!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: require(...).jsdom is not a function - Stack Overflow
Try using the following, var jsdom = require('jsdom'); const { JSDOM } = jsdom; const { document } = (new JSDOM('')).window; global.document ...
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 >
How to make PDF from HTML - General - Node-RED Forum
Unfortunately I get TypeError: JSDOM is not a constructor. with the following flow: [ { "id": "ee71cb46e6084549", "type": "template", ...
Read more >
jsdom | Best of JS
The JSDOM constructor accepts a second parameter which can be used to customize your jsdom in the following ways. Simple options. const dom...
Read more >
JSDOM: How to Get Started - Testim.io
Using JSDOM is very simple. JSDOM expects that you pass some valid HTML to its constructor. Then, it'll parse that HTML just like...
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