1

Update - see bottom of post

I'm trying to setup jquery in node.js and having some trouble. As described on SO I'm installing jquery with npm install jquery and am executing my javascript as a script from the command line, rather than running it as a server.

A few points to note:

  • OS X 10.7.3
  • node.js version 0.6.11
  • npm version 1.1.1
  • node-waf version 1.5.16

So, from the directory that contains my node script, I npm install jquery. Terminal then goes off for 5 seconds and does a few things, particularly, download the modules and build contextify. At the end, the message is 'build' finished successfully.

Also, from the install log I see:

  • htmlparser 1.7.4
  • jsdom 0.2.10

I try to run my script at this point: ./script.js, but this is output:

Internal Contextify ERROR: Make sure Contextify is build with your current Node version. 
To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'.

So, I do the following:

$ cd node_modules/jquery/node_modules/jsdom/node_modules/contextify/
$ node-waf distclean && node-waf configure build

'distclean' finished successfully (0.002s)
Setting srcdir to:     /proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify 
Setting blddir to:     /proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.729s)
Waf: Entering directory `/proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build'
[1/2] cxx: src/contextify.cc -> build/Release/src/contextify_1.o
[2/2] cxx_link: build/Release/src/contextify_1.o -> build/Release/contextify.node
Waf: Leaving directory `/proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build'
'build' finished successfully (3.335s)

However, I still get the Internal Contextify ERROR when I run my script. Below is the full error message:

Internal Contextify ERROR: Make sure Contextify is built with your current Node version.
To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: Unable to load shared library /proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
    at Object..node (module.js:472:11)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous>(/proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/lib/contextify.js:2:22)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)

It does seem strange to me that not found is the output of Checking for node path when compiling, but I don't know what to make of it other than that it is unexpected to me.

If anyone can offer any suggestions, I would greatly appreciate it!

Update - 2/21/12

After some more research, I have been able to fix the oddity of node path not being found. After executing: export NODE_PATH="/usr/local/lib/node" in terminal, node path is found during the build process. However, after removing the jquery module and installing/building again, I am still in the same situation.

The contextify.node file exists in the specified release directory, but it still cannot be loaded by my script.

Community
  • 1
  • 1
jmac
  • 1,129
  • 14
  • 28
  • In the mean time, you can manually create the file by the time someone answers this and explains why its happening. – Shawn Mclean Feb 21 '12 at 18:19
  • Thanks, Shawn. I'd be OK with that, but I'm not sure what file that would be (I'm pretty new to node.js). There is a contextify.node file that gets build in its release directory. Could explain a little more or point me to a reference? – jmac Feb 21 '12 at 18:23
  • Im pretty new too, but when I was using jquery, I just added a new js file and linked to it from one of the pages. Im using express framework. – Shawn Mclean Feb 21 '12 at 19:07

2 Answers2

3

So this appears to be an issue with 32-bit vs 64-bit and is specifically related to node.js v0.6.11 at this pont. Apparently Contextify is a 64-bit library, but the download of node.js 0.6.11 was a 32-bit executable. Downgrading to v0.6.10 appears to work for me.

Not sure what this means for the future, but here are the resources I found for anyone else interested:

jmac
  • 1,129
  • 14
  • 28
1

I fixed the contextify problem by following these instructions:

"For those who are used to the magic of npm, to use the pre-built binary from Benvie just download the ZIP file at https://github.com/Benvie/contextify/zipball/master , extract it into your node_modules folder, and then rename the folder to "contextify". Note that this binary only works in windows with node 0.6, so be careful if you're sharing your node_modules folder via source control with non-windows users. (edit: fixed the link as pointed out in the next comment)"

from https://github.com/brianmcd/contextify/issues/12

ruedaminute
  • 579
  • 2
  • 5
  • 13