我从https://github.com/bprodoehl/phantomjs/releases/下载了PhantomJS二进制文件,并在我的本地主机上测试通过。
打包并创建AWS Lambda函数。
有人有任何想法吗? 谢谢。
打包并创建AWS Lambda函数。
exports.handler = function (event, context) {
var path = require("path");
var Process = require("child_process");
Process.exec(path.join(__dirname,"./bin/phantomjs")+" --version", function (err, data) {
if (err) {
console.log(err.message);
context.fail(err.stack);
} else {
context.succeed(data);
}
})
}
但是当在Lambda中进行测试时,总是会得到以下错误:
{"errorMessage":"Error: Command failed: /bin/sh: /var/task/bin/phantomjs: Permission denied
at ChildProcess.exithandler (child_process.js:658:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Socket.<anonymous> (child_process.js:979:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:466:12)"}
有人有任何想法吗? 谢谢。