2012-02-21 83 views
1

更新 - 看帖子的底部無法與node.js的安裝jQuery的 - 無法加載Contextify

我想設置的jQuery在node.js中和遇到了一些麻煩。作爲described on SO我正在安裝jQuery與npm install jquery並執行我的JavaScript作爲腳本從命令行,而不是作爲服務器運行。

有幾點需要注意:

  • OS X 10.7.3
  • 的Node.js版本0.6.11
  • NPM版本1.1.1
  • 節點-WAF版本1.5.16

因此,從包含我的節點腳本的目錄I npm install jquery。然後,終端會關閉5秒鐘並執行一些操作,特別是下載模塊並構建調解。最後,該消息是'build' finished successfully

此外,從安裝日誌我看到:

  • 的HTMLParser 1.7.4
  • jsdom 0.2.10

我嘗試在這一點上運行我的腳本:./script.js,但這輸出:

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

因此,我做了以下操作:

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

但是,我仍然運行我的腳本時得到了Internal Contextify ERROR。以下是完整的錯誤消息:

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) 

它似乎奇怪,我not foundChecking for node path編譯時的輸出,但我不知道是怎麼打的比,這是不期而至我之外。

如果有人可以提供任何建議,我將不勝感激!

更新 - 12年2月21日

經過一些調查研究,我已經能夠解決未找到節點路徑的怪胎。在終端中執行:export NODE_PATH="/usr/local/lib/node"後,在構建過程中會找到節點路徑。但是,刪除jquery模塊並重新安裝/構建後,我仍處於相同的情況。

contextify.node文件存在於指定的版本目錄中,但仍無法通過我的腳本加載。

+0

在此同時,您可以通過一次有人回答了這個手動創建的文件,並解釋爲什麼它的發生 – 2012-02-21 18:19:48

+0

感謝。 ,Shawn,我可以這樣做,但是我不確定那個文件會是什麼(我對node.js非常陌生)。有一個contextify.node文件在它的release目錄中生成。多說一點,或者指點我參考? – jmac 2012-02-21 18:23:03

+0

我也很新,但是當我使用jQuery時,我只是添加了一個新的js文件並從其中一個頁面鏈接到它。 – 2012-02-21 19:07:52

回答

1

我固定contextify問題通過以下指令說明:

「對於那些習慣了npm魔法的人來說,使用Benvie預製的二進制文件就可以了在https://github.com/Benvie/contextify/zipball/master下載ZIP文件,將其解壓到您的node_modules文件夾中,然後將該文件夾重命名爲「contextify」。請注意,此二進制文件只能在節點爲0.6的窗口中使用,因此如果要通過非Windows用戶的源代碼管理共享您的node_modules文件夾,請小心。 (編輯:固定的聯繫,在接下來的評論中指出)」

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