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

回答済み 1年前
  • 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
エキスパート
回答済み 1年前
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
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ