Error: jQuery requires a window with a document

后端 未结 12 2331
说谎
说谎 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:20

    I solved it. had to first remove jsdom and jquery then npm install jsdom jquery.

    Then this:

    var jsdom = require("jsdom"); 
    $ = require("jquery")(jsdom.jsdom().createWindow()); 
    

    Turns out that it was important that I had the latest version. Otherwise it didn't work..

提交回复
热议问题