Unable to invoke Lambda function

0

I have encountered an issue when invoking my lambda function. Tried different methods to test the function (CLI, uploading the zip file directly to Lambda ), however none of them worked. After looking into the function log, the error seems to occur from an import that failed to execute. The lambda function is also attached (node 16.x). index.js

The following is a detail of the function log: Function Logs 2023-06-25T19:06:43.696Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'nanoid'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module 'nanoid'","Require stack:","- /var/task/index.js","- /var/runtime/index.mjs"," at _loadUserApp (file:///var/runtime/index.mjs:997:17)"," at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1032:21)"," at async start (file:///var/runtime/index.mjs:1195:23)"," at async file:///var/runtime/index.mjs:1201:1"]}

3개 답변
1

You can check resolution mentioned in similar post.

https://repost.aws/knowledge-center/lambda-import-module-error-nodejs

답변함 일 년 전
  • So in this case, do I include the nanoid in the node_modules then deploy the zipped file ?

0

Does your Lambda code contains a node_modules with the library installed?

profile picture
전문가
답변함 일 년 전
0

It looks like you are referencing a module 'nanoid' that is not available by default and that you have not included in your Lambda zip file. This should help you install module and include it in the zip file. https://stackoverflow.com/questions/34437900/how-to-load-npm-modules-in-aws-lambda

profile pictureAWS
전문가
iBehr
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠