Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

javascript - aws-lambda Cannot find module

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)"
  ]
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...