0

下载并运行 install.js npm phantom >> PhantomJS 已经安装在 /usr/local/bin/phantomjs。使用工作 Phantomjs 示例和 PizzaTest.js 创建一个文件 Pizza.js 来测试它。

var childProcess = require('child_process')
var phantomjs = require('phantomjs')
var binPath = phantomjs.path

var childArgs = [
  path.join(__dirname, 'pizza.js'),
]

childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
  console.log(stdout);
})

收到错误:

/home/khaljava/coder/phantom/pizzaTest.js:6
  path.join(__dirname, 'pizza.js'),
  ^
4

1 回答 1

0

只需要添加

var path = require('path');
于 2013-08-24T21:14:51.243 回答