Can I use jQuery with Node.js?

前端 未结 20 2028
清歌不尽
清歌不尽 2020-11-22 05:42

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

20条回答
  •  Happy的楠姐
    2020-11-22 06:10

    The module jsdom is a great tool. But if you want to evaluate entire pages and do some funky stuff on them server side I suggest running them in their own context:

    vm.runInContext
    

    So things like require / CommonJS on site will not blow your Node process itself.

    You can find documentation here. Cheers!

提交回复
热议问题