2012-03-24 51 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