jsvine / notebookjs

Render Jupyter/IPython notebooks on the fly, in the browser. (Or on the command line, if you'd like.)
MIT License
274 stars 48 forks source link

require("jsdom").jsdom() is not a function #13

Closed jithurjacob closed 6 years ago

jithurjacob commented 6 years ago

I'm trying to create a VS code extension that could render ipython notebooks. I'm getting require("jsdom").jsdom() is not a function error function when using the following code

     ` var fs = require ("fs");
       var nb = require("notebookjs");             
        var ipynb = JSON.parse(fs.readFileSync(filePath));
        var notebook = nb.parse(ipynb);
        console.log(notebook.render().outerHTML);  `

It seems like this issue is happening across various libraries. I have been to able to solve this by referencing the following comment.

https://github.com/airbnb/enzyme/issues/942#issuecomment-314715229

The updated code is

`var jsdom = require('jsdom');
const { JSDOM } = jsdom;

const { document } = (new JSDOM('')).window;
var doc = root.document || document;`

It would be great if you could test the code and push a new version?

jsvine commented 6 years ago

Thanks @jithurjacob! This seems to have been the result of a breaking change in JSDOM. I've added a fix, and updated the JSDOM version in the package requirements. Should be working in the just-published notebookjs==0.3.0. Let me know if you're still having trouble.