15

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!

ngryman
  • 7,112
  • 2
  • 26
  • 23
  • 1
    Why do you use x64 version (I guess)? 32 bit version work well for me on Windows 7 x64. – nguyenkha Apr 19 '12 at 13:07
  • x64 is just the version of my OS. – ngryman Apr 19 '12 at 16:47
  • Because I see http://nodejs.org/dist/v0.6.14/x64/node.lib. Do you use 64bit version of Node.js. I use Node 32bit on Win7 x64 and contextify works fine – nguyenkha Apr 19 '12 at 17:27
  • 1
    You can try: update to node 0.6.15, switch to Python 2.7 :-? It could be not compatible with Python 3 and did you have Visual C++ installed? – nguyenkha Apr 19 '12 at 17:40
  • Ok ! Updated to node 0.6.15 (32 bits), Python 2.7 (32 bits) it works like charm :) Thanks ! – ngryman Apr 20 '12 at 09:34
  • I have Visual Studio Express installed, I don't know if it makes the difference. I bet for a 32bits / 64bits conflict, or something like that – ngryman Apr 20 '12 at 09:35

7 Answers7

14

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.

mihai
  • 37,072
  • 9
  • 60
  • 86
  • 1
    Thanks a lot :) Even if I still don't know how to build it, this solve my problem. – ngryman Apr 20 '12 at 09:19
  • Binaries are a huge help (thankyou!), but devs should note they were last updated April 2012. – Simon East Mar 31 '13 at 06:54
  • @Simon you're right, however these are no longer needed. `jsdom` and `contextify` now install ok just with `npm install` – mihai Mar 31 '13 at 09:34
  • @mihai are you sure?? It definitely didn't install for me yesterday. Don't you still need Python and MS C++ compiler? (Unless I had a different issue?) – Simon East Apr 01 '13 at 11:23
  • @Simon you still need python and a MS C++ compiler. The requirements are listed in the readme for [node-gyp](https://github.com/TooTallNate/node-gyp), which is the tool used by npm to build native modules. – mihai Apr 01 '13 at 21:47
  • 4
    @mihai Oh dear, so it's *still really painful*, and binaries might still be helpful. I don't want to have to download and install 600mb+ Visual Studio Express just to install a simple node module. – Simon East Apr 02 '13 at 00:27
  • 2
    on an x64 Win7 computer with VS 2010 Express it only worked when I added *--arch=ia32*, e.g. `npm install jsdom --arch=ia32`. Without, it failed with "InvalidPlatform...error MSB8007". Hat tip to https://github.com/node-xmpp/node-expat/issues/59 – matt wilkie Feb 08 '14 at 06:57
  • OMG +1,000... clicking "Show more comments" saved my life, thanks @mattwilkie – Wes Johnson Mar 14 '14 at 04:57
  • < Update (march 2013) ^ I still can't install it – Ilya Buziuk Jul 17 '14 at 10:48
  • Thank you kindly Mihai! Just lost 2h with this. – Dragos Rusu Oct 14 '15 at 18:49
  • @mihai I'm unable to install contextify – hackp0int Dec 18 '15 at 22:00
3

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:

┬ jquery@1.7.3
├── htmlparser@1.7.6
├─┬ jsdom@0.2.19
│ ├─┬ contextify@0.1.3
│ │ └── bindings@1.0.0
│ ├── cssom@0.2.5
│ ├── cssstyle@0.2.3
│ └─┬ request@2.11.4
│   ├─┬ form-data@0.0.4
│   │ ├── async@0.1.22
│   │ └─┬ combined-stream@0.0.3
│   │   └── delayed-stream@0.0.5
│   └── mime@1.2.7
├── location@0.0.1
├── navigator@1.0.1
└── xmlhttprequest@1.4.2

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.

George
  • 1,552
  • 1
  • 17
  • 26
3

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/

Simon East
  • 55,742
  • 17
  • 139
  • 133
2

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).

AndiDog
  • 68,631
  • 21
  • 159
  • 205
1

From the jsdom readme.md:

Windows

  • A recent copy of the x86 version of [Node.js for Windows], not the x64 version.
  • A copy of Visual C++ 2010 Express.
  • A copy of [Python 2.7], installed in the default location of C:\Python27.

I did exactly this and it worked fine, except that for me the x64 version worked as well.

1

The easiest way is to install the windows-build-tools package. That has everything you need to build contextify. Run the command from an power shell prompt running with administrator rights.

npm install --global --production windows-build-tools

https://www.npmjs.com/package/windows-build-tools

These tools are required to compile popular native modules. It will also install Python 2.7, configuring your machine and npm appropriately.

Contents

  • Visual C++ Compilers (targeting x86, X64 and ARM)
  • Visual C++ Compilers (targeting x86, X64 and ARM)
  • Visual C++ headers & libraries (CRT & STL)
  • Visual C++ build scripts (targeting Windows desktop)
  • Microsoft Build Tools 2015 (MSBuild)
  • Windows SDK 8.1 (optional, on by default)
  • Windows SDK 10 (optional, off by default)
  • ATL and MFC (optional, off by default)
  • C++ Build tools specific command prompts
Padhraic
  • 5,112
  • 4
  • 30
  • 39
0

I had to make sure I was using Python 2.7.3 and running the cmd line as administrator (right click run as administrator).

> python --version

I built it using

  • Windows 7 x64
  • Python 2.7.3
  • Node 0.8.17
  • Visual Studio 10
Joey V.
  • 1,866
  • 1
  • 22
  • 18