Problems directly using PhantomJS in node.js

丶灬走出姿态 提交于 2019-12-08 14:29:51

问题


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();

I get the error:

Error: Cannot find module 'webpage'

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


回答1:


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

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

phantomjs hello.js

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



来源:https://stackoverflow.com/questions/15487321/problems-directly-using-phantomjs-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!