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
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.
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:
This recipe can be found in it's original form on Stack Over Flow.