在node.js中直接使用PhantomJS的问题 [英] Problems directly using PhantomJS in node.js

查看:283
本文介绍了在node.js中直接使用PhantomJS的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PhantomJS,并且已经通过NPM安装了它. 我似乎无法运行任何一个示例,实际上我什至无法运行:

I'm attempting to use PhantomJS, and I've installed it via NPM. I can't seem to run any of the of the examples, in fact I can't even run:

var page = require('webpage').create();

我得到了错误:

Error: Cannot find module 'webpage'

我有什么想念的吗?我正在使用通过NPM在同一目录中安装的其他一些模块,没有任何问题

Is there anything i'm missing? I'm using a few other modules that I've installed via NPM in the same directory with no issues

推荐答案

对于Node.js,PhantomJS 不是.您可能通过node二进制文件来运行示例.

PhantomJS is not for Node.js. You are likely running the examples through node binary.

仔细阅读入门文档,您会发现每个PhantomJS示例都需要调用方式如下:

Read the Getting Started documentation carefully and you'll see that every single PhantomJS example need to be invoked like:

phantomjs hello.js

请注意,Node.js和PhantomJS之间有一个 bridge .在这种情况下,您需要遵循特定桥梁的给定示例(有一些不同的示例).

Note that there is a bridge between Node.js and PhantomJS. In that case, you need to follow the given examples for that particular bridge (there are a few different ones).

这篇关于在node.js中直接使用PhantomJS的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆