Error: jQuery requires a window with a document

后端 未结 12 2325
说谎
说谎 2020-11-29 00:43

So everything was working just fine and great until doing npm update and now things do not work quite as they used to.

A little background: in my code I use jquery

12条回答
  •  独厮守ぢ
    2020-11-29 01:16

    I plopped this on the top of my Node.js (server) file that uses jQuery to help render html text ...

    var jsdom = require("jsdom").jsdom;
    jsdom.env({
        html : "",
        done : function(errs, window) {
            global.window = window;
        }
    });
    

    and everything comes up roses.

提交回复
热议问题