Error: jQuery requires a window with a document

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

    node.js-jQuery definition in one line:

    // definition
    var $ = require('jquery')(require("jsdom").jsdom().parentWindow);
    
    // usage
    $("body").append("
    TEST
    "); console.log($("body").html());

提交回复
热议问题