2012-03-24 188 views
12

我遇到了問題,能否指點我正確的方向?如何在Windows 7上安裝Zombie JS? (node.js無頭瀏覽器)

編輯:這個模塊(Contextify)不會從Windows上的npm安裝。有關更多信息,請參閱https://github.com/brianmcd/contextify/issues/10

這是因爲故宮不支持C++模塊在Windows上尚未:https://github.com/brianmcd/contextify/issues/14#issuecomment-3577972

一般來說,我想運行http://zombie.labnotes.org - 適用於Windows,他們所提出的建議:

在Windows上,你需要的Cygwin以訪問GCC,Python等閱讀 本作的詳細說明和故障排除:https://github.com/joyent/node/wiki/Building-node.js-on-Cygwin-(Windows)

的問題是 - 他們說的Cygwin描述已過時,並建議使用Visual Studio ...無論哪種方式,我得到了兩個,我通過使用nodejs安裝程序,而不是從頭開始構建它(錯誤似乎並不相關)。這裏是我做的步驟:使用安裝程序

1)安裝的node.js:http://nodejs.org/#download

2)得到NPM包管理器:https://github.com/isaacs/npm

3)得到的Python 2.7,Visual Studio 2010中(一些來源的指示的C++編譯器根據需要)和Cygwin ...

4)由於安裝在contextify失敗我搜索it

使用預製的二進制剛纔下載的ZIP文件在 https://github.com/Benvie/contextify/zipball/master,將其解壓縮到 你node_modules文件夾,然後重命名文件夾「contextify」

c:\Program Files (x86)\nodejs>node --version 
v0.6.13 

c:\Program Files (x86)\nodejs>npm install zombie 
npm http GET https://registry.npmjs.org/zombie 
npm http 304 https://registry.npmjs.org/zombie 
npm http GET https://registry.npmjs.org/ws 
npm http GET https://registry.npmjs.org/jsdom/0.2.10 
npm http GET https://registry.npmjs.org/mime 
npm http GET https://registry.npmjs.org/coffee-script 
npm http 304 https://registry.npmjs.org/ws 
npm http 304 https://registry.npmjs.org/mime 
npm http 304 https://registry.npmjs.org/jsdom/0.2.10 
npm http 304 https://registry.npmjs.org/coffee-script 

> [email protected] preinstall c:\Program Files (x86)\nodejs\node_modules\zombie\node_mo 
dules\ws 
> make 

     1 file(s) copied. 
     1 file(s) copied. 
npm http GET https://registry.npmjs.org/commander/0.5.0 
npm http GET https://registry.npmjs.org/options 
npm http 304 https://registry.npmjs.org/options 
npm http 304 https://registry.npmjs.org/commander/0.5.0 
npm http GET https://registry.npmjs.org/contextify 
npm http GET https://registry.npmjs.org/request 
npm http GET https://registry.npmjs.org/htmlparser 
npm http GET https://registry.npmjs.org/cssom 
npm http 304 https://registry.npmjs.org/contextify 
npm http 304 https://registry.npmjs.org/htmlparser 
npm http 304 https://registry.npmjs.org/request 
npm http 304 https://registry.npmjs.org/cssom 

> [email protected] preinstall c:\Program Files (x86)\nodejs\node_modules\zombie\ 
node_modules\jsdom\node_modules\contextify 
> node-waf clean || (exit 0); node-waf configure build 

node-waf was unexpected at this time. 

npm ERR! Error: ENOENT, chmod 'c:\Program Files (x86)\nodejs\node_modules\zombie 
\node_modules\jsdom\node_modules\request\tests\squid.conf' 
npm ERR! You may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 
npm ERR! 
npm ERR! System Windows_NT 6.1.7600 
npm ERR! command "c:\\Program Files (x86)\\nodejs\\\\node.exe" "c:\\Program File 
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "zombie" 
npm ERR! cwd c:\Program Files (x86)\nodejs 
npm ERR! node -v v0.6.13 
npm ERR! npm -v 1.1.9 
npm ERR! path c:\Program Files (x86)\nodejs\node_modules\zombie\node_modules\jsd 
om\node_modules\request\tests\squid.conf 
npm ERR! fstream_path c:\Program Files (x86)\nodejs\node_modules\zombie\node_mod 
ules\jsdom\node_modules\request\tests\squid.conf 
npm ERR! fstream_type File 
npm ERR! fstream_class FileWriter 
npm ERR! fstream_finish_call chmod 
npm ERR! code ENOENT 
npm ERR! message ENOENT, chmod 'c:\Program Files (x86)\nodejs\node_modules\zombi 
e\node_modules\jsdom\node_modules\request\tests\squid.conf' 
npm ERR! errno {} 
npm ERR! fstream_stack Object.oncomplete (c:\Program Files (x86)\nodejs\node_mod 
ules\npm\node_modules\fstream\lib\writer.js:285:17) 

npm ERR! Error: ENOENT, lstat 'c:\Program Files (x86)\nodejs\node_modules\zombie 
\node_modules\jsdom\node_modules\htmlparser\runtests.html' 
npm ERR! You may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 
npm ERR! 
npm ERR! System Windows_NT 6.1.7600 
npm ERR! command "c:\\Program Files (x86)\\nodejs\\\\node.exe" "c:\\Program File 
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "zombie" 
npm ERR! cwd c:\Program Files (x86)\nodejs 
npm ERR! node -v v0.6.13 
npm ERR! npm -v 1.1.9 
npm ERR! path c:\Program Files (x86)\nodejs\node_modules\zombie\node_modules\jsd 
om\node_modules\htmlparser\runtests.html 
npm ERR! fstream_path c:\Program Files (x86)\nodejs\node_modules\zombie\node_mod 
ules\jsdom\node_modules\htmlparser\runtests.html 
npm ERR! fstream_type File 
npm ERR! fstream_class FileWriter 
npm ERR! code ENOENT 
npm ERR! message ENOENT, lstat 'c:\Program Files (x86)\nodejs\node_modules\zombi 
e\node_modules\jsdom\node_modules\htmlparser\runtests.html' 
npm ERR! errno {} 
npm ERR! fstream_stack Object.oncomplete (c:\Program Files (x86)\nodejs\node_mod 
ules\npm\node_modules\fstream\lib\writer.js:204:26) 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  c:\Program Files (x86)\nodejs\npm-debug.log 
npm not ok 

c:\Program Files (x86)\nodejs> 

什麼步驟,我需要做的爲了使其運作?

如果建設從源到的NodeJS安裝需要一個包,那麼請大聲說出來:)

感謝您的幫助!

回答

10

這並不直接回答你的問題,但它可以幫助你解決你想要使用Zombie.js的問題,並且可能是其他SOers的良好信息。

在Node v0.6的這個階段,你將會爲了讓Zombie.js在Windows上工作而打一場艱苦的戰鬥。從v0.8節點開始,從node-waf切換到node-gyp會更好一些。然而,如果你想要真正的無頭瀏覽器環境,你可以看看PhantomJSCasperJS(PhantomJS的測試框架)。它不是一個Node模塊,但它運行得非常好,並且是一個真正的無頭瀏覽器,與Zombie.js不同,它是一種模擬類型。 PhantomJS在Windows上運行良好。

希望這可能有助於您的Windows網站測試/抓取需求。

+0

如果我需要支持cookie? http://stackoverflow.com/questions/9504765/does-phantomjs-support-cookies (我將運行Ubuntu然後) – 2012-03-24 15:23:30

+0

它可以正常使用Cookies。 PhantomJS腳本本身無法訪問Cookie。即您在PhantomJS中打開的任何網頁都可以正常使用Cookie,而不是您的PhantomJS腳本。 – 2012-03-24 15:34:50

+0

好了,那就試試看吧。我擔心我甚至無法接受cookie:http://code.google.com/p/phantomjs/issues/detail?id=91感謝您的幫助! – 2012-03-24 15:37:28

9

我有zombiejs在Windows窗口上成功運行。我不必使用cygwin。

我有我的盒子下面的版本:

  • 節點0.8.17
  • 的Python 2.7.3
  • Visual Studio 2010中

之後,請確保您正在運行以管理員身份運行cmd行,並運行殭屍的安裝命令。

npm install zombie

+1

_Visual Studio 2010_對我來說很重要!出於某種原因,Visual Studio 2012無法正常工作。 – Ilya 2013-04-18 15:43:25

+1

Python 2.7 + VS2012爲我完成了這項工作。奇怪的一個位。 – 2014-01-24 10:16:35

+0

與上面的Ed Woodcock相同,使用Python 2.7.3對我很好。祝大家好運。 – larryq 2014-02-21 20:16:50

1

如果你的Visual Studio 2013(而不是Visual Studio 2010中)以下內容添加到您的NPM命令:

--msvs_version = 2013