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 réponses
1

You can check resolution mentioned in similar post.

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

répondu il y a un an
  • 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
EXPERT
répondu il y a un an
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
EXPERT
iBehr
répondu il y a un an
  • I have double checked my file directory and nanoid is imported

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions