Use jQuery in Node without installing Python/VCBuild.exe

161 views Asked by At

I'm trying to write a Node application which uses jQuery.

To use jQuery in Node, you need to provide it with a window object. There seem to be a number of ways to do this, but the most common seems to be to use JSDom to create the window object.

The problem is, to use JSDom, you need to install both Python and have VCBuild.exe available (and get the PATH set up properly).

This greatly increases the difficulty of sharing what I'm writing with the rest of my team. They'd each have to set up these additional dependencies on their computer, meaning it's a lot more complicated than just "clone repo and run npm install".

Does anyone have any suggestions?

2

There are 2 answers

0
Naharia Pesek On BEST ANSWER

I would suggest using cheerio

Tiny, fast, and elegant implementation of core jQuery designed specifically for the server

3
sagie On

don't use jquery in node. really. i needed the jquery extends capability and someone wrote a node module for that (node.extends). every functionality you need, you will have a node module for. trust me. don't go with putting pure client library in server.

there are libraries which are good for both client/server like underscore but they are rare and even underscore is packaged as a node module for nodejs.