Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building contextify under Windows 7 x64 (for NodeJS jQuery)

I try to get node-jquery working. contextify is one of the dependencies (required for jsdom).

contextify needs to be built somehow using Python. But this does not seem to work on Windows 7 x64. At least one my computer :)

After some readings (#10, #12, #17) and trying some binaries provided by this fork and this one I can get it work ...

I've got the same error from node-gyp configure or from node-gyp rebuild (npm install jquery) :

info it worked if it ends with ok
info downloading: http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz
info downloading: http://nodejs.org/dist/v0.6.14/x64/node.lib
info downloading: http://nodejs.org/dist/v0.6.14/node.lib
spawn python [ 'D:\\Users\\ngryman\\.node-gyp\\0.6.14\\tools\\gyp_addon',
  'binding.gyp',
  '-ID:\\Users\\ngryman\\build\\config.gypi',
  '-f',
  'msvs',
  '-G',
  'msvs_version=2010' ]
  File "D:\Users\ngryman\.node-gyp\0.6.14\tools\gyp_addon", line 40
    print 'Error running GYP'
                        ^
SyntaxError: invalid syntax
ERR! Error: `gyp_addon` failed with exit code: 1
  at ChildProcess.onCpExit (D:\Users\ngryman\AppData\Roaming\npm\node_modules
node-gyp\lib\configure.js:226:16)
  at ChildProcess.emit (events.js:70:17)
  at maybeExit (child_process.js:360:16)
  at Process.onexit (child_process.js:396:5)
ERR! not ok

It seems there is a syntax error ... I am not very comfortable with Python.

Here are my versions :

  • Python: 3.2.3
  • NodeJS: 0.6.14

Anyone have an idea?

Thanks!

like image 866
ngryman Avatar asked Apr 19 '12 10:04

ngryman


4 Answers

I managed to build it, but I can say it was really painful. In fact it was so painful that it caused temporary amnesia and I forgot how I did it.

You need Visual Studio as well, apart from python.

Anyway, I have the binaries, I just uploaded them to gihub:
https://github.com/mihaifm/jsdom_binaries

Just clone that repo, copy what's inside node_modules to your project, and you're good to go!

Update (march 2013)

These binaries are no longer needed (at least not for Win7, with VS2010 installed). jsdom and contextify can now be installed just with npm:

npm install jsdom
npm install contextify

(you still need python and a MS C++ compiler, as mentioned in the requirements for node-gyp)

I updated the repo as well, just in case anyone still has trouble installing.

like image 89
mihai Avatar answered Sep 22 '22 23:09

mihai


I was able to successfully build node-jquery on Windows 7(x64) with node 0.8.11(x64), and Python 2.7.3. Here's what my jquery structure looks like:

[email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│   ├─┬ [email protected]
│   │ ├── [email protected]
│   │ └─┬ [email protected]
│   │   └── [email protected]
│   └── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

according to the author of node-gyp https://github.com/TooTallNate/node-gyp/issues/155

Ya, Python 3 and Python 2 are not compatible, however gyp requires Python 2.

like image 43
George Avatar answered Sep 21 '22 23:09

George


If you don't need the full feature-set of Contextify, Cheerio is much faster and much easier to install on Windows, and provides most of the jQuery functions you would use server-side.

http://matthewmueller.github.com/cheerio/

like image 32
Simon East Avatar answered Sep 23 '22 23:09

Simon East


I built it using

  • Windows 8 x64 DP
  • Python 2.7 (on PATH)
  • Node 0.8.11 x86 (on PATH)
  • Visual Studio 2010 (requires installed 'Visual C++' feature)

contextify 0.1.3 binaries (probably only working with the 32-bit Node version) can be found at my GitHub repo. They work together with jsdom 0.2.18 (current version as of 2012-10-13).

like image 40
AndiDog Avatar answered Sep 20 '22 23:09

AndiDog