【发布时间】:2015-04-18 11:13:03
【问题描述】:
我确实安装了 PhantomJS,但是当我运行我的 Node.js 代码时出现错误(您没有安装“phantomjs”):
var modules = '/home/engine/node_modules/';
var path = require('path');
var childProcess = require('child_process');
var phantom = require(modules+'phantom');
var binPath = phantom.path;
phantom.create(function(browser){ // Error happens here I think because the module is found
// browser.createPage(function (page){});
});
如果在 console.log binPath 我得到未定义。
但是在 PuTTY 中,如果我:
cd ~/phantomjs/
[root@engine phantomjs]# bin/phantomjs
phantomjs>
我是不是安装错地方了?
【问题讨论】:
-
是否在PATH变量中?
-
你是怎么安装的? npm install -g phantomjs ?
-
node 模块找到了,但是 phantomjs bin 的东西不是