aws-lambda 找不到模块 [英] aws-lambda Cannot find module

查看:41
本文介绍了aws-lambda 找不到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 zip 文件上传代码时,我不断在 aws-lambda 控制台中收到此错误.我尝试上传其他 zip 文件,它们工作正常..js 文件在 zip 文件中名为CreateThumbnail.js".我相信处理程序也被正确命名为CreateThumbnail.handler".node_modules 子目录也已设置.有人知道吗?

I keep getting this error in the aws-lambda console when uploading code from a zip file. I have tried uploading other zip files and they work correctly. The .js file is named "CreateThumbnail.js" in the zip file. I believe the handler is also named properly "CreateThumbnail.handler". the node_modules subdirectory is also setup. Anyone have any idea?

{
  "errorMessage": "Cannot find module 'CreateThumbnail'",
  "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)"
  ]
}

推荐答案

我能够让它发挥作用的方式是:

The way I was able to get this to work was:

  1. 将文件命名为exports.js
  2. 在文件中将处理程序命名为exports.handler
  3. 将 lambda 配置中的处理程序设置为exports.handler
  4. 仅压缩文件夹的内容,而不是文件夹本身(如上所述)并重命名 zip 文件exports.zip

这篇关于aws-lambda 找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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