[英]Phantomjs on windows
我有以下非常簡單的代碼:
var phantom = require('phantomjs');
phantom.create(function(ph){
ph.createPage(function(page) {
page.open("http://www.google.com", function(status) {
page.render('google.pdf', function(){
console.log('Page Rendered');
ph.exit();
});
});
});
});
當我運行它時,我在phantom.create()
行上得到undefined is not a function
錯誤
我現在正坐在Windows機器上,閱讀某處可能需要使用dnode
我的問題是這是導致錯誤的原因,還是代碼中可能存在錯誤?
更新
我已經將var phantom = requiere(phantomjs)
更改為var phantom = requiere(phantom)
,但是現在我得到了錯誤:
phantom stderr: 'phantomjs' is not recognised as an internal or external kommand, a program or a batchfil.
...
AssertionError: abnormal phantomjs exit code: 1
您在phantomjs
和phantom
node.js模塊之間phantomjs
。
您的代碼遵循phantom
模塊的模式,如下所示: https ://www.npmjs.com/package/phantom(這是phantomjs的節點包裝器)
因此,需要phantom,而不是phantomjs
確保在此之前運行npm install phantom
var phantom = require('phantom'); //not phantomjs
phantom.create(function(ph){
ph.createPage(function(page) {
page.open("http://www.google.com", function(status) {
page.render('google.pdf', function(){
console.log('Page Rendered');
ph.exit();
});
});
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.