Encountering "Cannot find module" Error When Using ESM Module as AWS Lambda Layer Handler #6270
Unanswered
aryamohanan
asked this question in
Q&A
Replies: 1 comment
-
Cross posting the question aws/aws-sdk-js#4651 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to define an ES module as a handler located in an AWS Lambda layer? We are currently transitioning from shipping the handler as a CommonJS module using dynamic imports to using a pure ES module (ESM). However, when setting up this pure ES module in the AWS Lambda layer handler, we encounter the following error:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'aws-lambda-auto-wrap-esm'\nRequire stack:\n- /var/runtime/index.mjs",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'aws-lambda-auto-wrap-esm'",
"Require stack:",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:https:///var/runtime/index.mjs:1087:17)",
" at async UserFunction.js.module.exports.load (file:https:///var/runtime/index.mjs:1119:21)",
" at async start (file:https:///var/runtime/index.mjs:1282:23)",
" at async file:https:///var/runtime/index.mjs:1288:1"
]
}
We are using Node.js version 18
Any insights or assistance would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions