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

查看:155
本文介绍了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

  1. Name the file exports.js
  2. Name the handler, within the file, exports.handler
  3. Set the handler in the lambda config to exports.handler
  4. Zip up only the contents of the folder, not the folder itself (as mentioned above) and rename the zip file exports.zip

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

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