New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAM local invocation with CDK generated template with typescript not able to find module index (index.mjs) #7048
Comments
Hey @Schwar999, thanks for raising the issue. To help us reproduce the issue, can you please share your Lambda Function Construct in CDK and corresponding Lambda Function Resource in synth-ed template? |
@hawflau Here are some of my codes. Synth-ed template
stack.ts
lambda.ts
|
I've tried to reproduce this issue however I was able to invoke the function locally. Here is the folder structure;
Here are the contents of the files;
I've used your Can you provide a reproducible example? |
Closing the issue, please reopen or create a new issue if you encounter any other problems. |
|
Issue
I'm trying to test a typescript lambda test made with CDK using SAM local invocation.
I did sam local "invoke -t stack.template.json" to test lambda, but I got the following error: "Error: Cannot find module 'index'“, ‘Require stack:’,”- /var/runtime/index.mjs Error."
The configuration in tsconfig.ts uses a CommonJS module with a ES2020 target.
I am trying to figure out why this error occurred, and I am thinking that SAM probably tried to invoke ES2020 modules instead of CommonJS.
I want to change the SAM local invocation so it can resolve to CommonJS.
I confirmed the result in a console, and it said that "index.js" was made using "cdk deploy", not "index.mjs".
Error code
tsconfig.json
ENV
Docker
The text was updated successfully, but these errors were encountered: