node.js - Phantomjscloud 无法与 aws lambda nodejs 一起使用

标签 node.js amazon-web-services phantomjs aws-lambda

感觉创建 AWS lambda 函数很痛苦,但当我将相同的服务从 GCF 移植到 lambda 并在处理函数(如 aws lambda 中的上下文)中进行一些更改并部署项目的 .zip 时,我能够使用 Google Cloud Function 轻松部署相同的微服务。它开始抛出如下所示的未知错误。 lambda 函数在本地环境中运行良好,

{
  "errorMessage": "callback called with Error argument, but there was a problem while retrieving one or more of its message, name, and stack"
}

日志显示代码开始处的父脚本中存在语法错误,但我通过运行node index.js确认了index.js中没有语法错误,无论如何我都在底部附加了index.js的代码片段

START RequestId: 7260c7a9-0adb-11e7-b923-aff6d9a52d2d Version: $LATEST Syntax error in module 'index': SyntaxError END RequestId: 7260c7a9-0adb-11e7-b923-aff6d9a52d2d

我开始缩小导致问题的软件范围,删除所有依赖项并开始一一包含,每次上传 zip 时都运行 lambda,最终找到导致问题的罪魁祸首,是 phantomjscloud 导致了问题。

当我包含 const phantomJsCloud = require('phantomjscloud') 时,它会抛出该错误,即使我的 npm_modules 也包含 phantomjscloud 模块。 aws lambda 和 phanthomjscloud 之间是否存在任何已知的故障,不知道如何解决此问题,如果您觉得我遗漏了任何内容,请随时询问任何信息。

这里的代码在不包含 const phantomJsCloud = require('phantomjscloud') 的情况下运行良好

global.async = require('async');
global.ImageHelpers = require('./services/ImageHelpers');
global.SimpleStorage = require('./services/SimpleStorage');
global.uuid = require('uuid');
global.path = require('path');

const phantomJsCloud = require('phantomjscloud')
const aadhaarController = require('./controllers/Aadhaar')
exports.handler = (event, context) => {
    // TODO implement
    aadhaarController.generateAadhaarCard(event,context);
};

包含 phantomjscloud 时来自 aws lambda 函数的错误消息:

Error message from aws lambda function when phantomjscloud is included

最佳答案

AWS 使用的 Node 版本 4.3 不支持 phantomjscloud,这就是它只能与运行时环境为 6.9.2 的谷歌云功能一起使用的原因,现在它已由作者修复,如果您看到这个答案,您可能正在使用 phantomjscloud 不支持的其他版本的 Node ,提出 github 问题解决了问题

关于node.js - Phantomjscloud 无法与 aws lambda nodejs 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42850980/

相关文章:

javascript - 如何使用自定义 jsonification 对包含对象的数组进行 jsonify

java - Node 缓冲区打印问题

python - 在 Python 中使用 PhantomJS 向下滚动到无限页面的底部

javascript - PhantomJS 使用太多线程

javascript - 如何在 horseman 的 [phantom for node.js] evaluate() 中使用 jqueryeach() 函数来模拟多次点击?

node.js - 用于推送通知的 Slack API 客户端

android - 使用 Android 云将图像发送到设备消息传递框架

amazon-web-services - 使用 Elastic Beanstalk 将多 docker 本地设置部署到 AWS

java - AWS Elastic Beanstalk 中的容器选项

node.js - Angular-cli 种子项目没有 Bower、Grunt、gulp,它如何管理所有依赖项?