AWS Lambda Function将返回“找不到模块'索引'".但配置中的处理程序设置为索引 [英] AWS Lambda Function is returning "Cannot find module 'index'" yet the handler in the config is set to index

查看:111
本文介绍了AWS Lambda Function将返回“找不到模块'索引'".但配置中的处理程序设置为索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我的标题所述,我遇到以下错误:

As my title explains I am getting the following error:

 {
  "errorMessage": "Cannot find module 'index'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._resolveFilename (module.js:338:15)",
    "Function.Module._load (module.js:280:25)",
    "Module.require (module.js:364:17)",
    "require (module.js:380:17)"
  ]
}

我尝试了 creating-a-中提供的两种解决方案lambda-function-in-aws-from-zip文件 simple-node-js-example-in-aws-lambda

我的配置当前如下所示:

My config currently looks like:

,我的文件结构是:

and my file structure is:

和我的index.js处理函数看起来像:

and my index.js handler function looks like :

exports.handler = function(event, context) {

除了以上两个答案中所述的以外,还有什么可能导致此问题?我已经尝试了两种解决方案,并且还为函数分配了更多的内存,以防万一这就是为什么它无法运行的原因.

What else could be causing this issue aside from what was stated in those two answers above? I have tried both solutions and I have also allocated more memory to the function just incase thats why it couldn't run.

编辑- 为了进行尝试,我为原始代码创建了一个更简单的版本,它看起来像这样:

EDIT - For the sake of trying, I created an even simpler version of my original code and it looked like this:

var Q = require('q');
var AWS = require('aws-sdk');
var validate = require('lambduh-validate');
var Lambda = new AWS.Lambda();
var S3 = new AWS.S3();




theHandler = function (event, context) {

  console.log =('nothing');

}

exports.handler = theHandler();

但是仍然无法解决相同的错误吗?

And yet still does not work with the same error?

推荐答案

尝试压缩并上传lambda-create-timelapse文件夹的内容.不是文件夹本身.

Try zipping and uploading the contents of the folder lambda-create-timelapse. Not the folder itself.

这篇关于AWS Lambda Function将返回“找不到模块'索引'".但配置中的处理程序设置为索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆