-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
VStudio Debug for Typescript Lambda function gives Runtime.ImportModuleError #7179
Comments
Hi there, Looking at the details, why are you running Also, how did you create this debug configuration? It seems it is different than what VSCode gives as example when you try to run debug there. Can you test it with the debugging configuration which is generated by AWS Toolkits plugin in VSCode to see if it is going to work? Thanks! |
Hi Mehmet, Thank you for your note. I am new to SAM and didn't know that With respect to the debug configuration, I picked that from some example online and it works fine for the non Typescript (.mjs) hello-world lambda example I have so I am using the same structure for this Typescript example. I am not sure how to get VSCode to generate the debug configuration you are referring to for the TS hello-world lambda function. If you can point me to that (or post a sample) I can give it a try - I take it that is different from what I have. On that note, do you see something missing from the current debug configuration? Also it is not clear why the error talks about index.mjs file (that I don't see anywhere) and the missing app module when it seems to be in the right place. It might have something to do with the fact that the transpiled file app.js is under the build directory in a different location and it might need some Typescript specific flag in the debug configuration but not sure if/what that may be. Thank you for your help. |
Following the advice in this YT video I changed the configuration to that below below and was able to step into the code. However this seems like a round about way of doing so through another file. However I am able to move forward here but had to do a local install of ts-node (otherwise I was getting an error that it didn't understand ts-node/register in config). Seems like there is probably a more direct and cleaner way - if so, would be happy to learn that.
|
I was having issues with reading a credential environment variable file with above configuration but while the code gets the filename passed through the GOOGLE_APPLICATION_CREDENTIALS envrionment variable below, it is not able to locate the file itself
I get the error Code is trying to read credential through
I added the projectRoot in the config above and also tried projectFolder attribute instead, with the file located directly under the gt-lambda-ts/hello-world directory but the code is unable to find and read that To understand the configuration options better I looked up the configuration options here but I don't see any options as configured above e.g. I don't see "launch" as an option for "type" anywhere. Issues I am trying to address -
Thank you for any pointers/help. PS: I was debating whether to start a new issue on this but since it is related TypeScript Debug I decided to continue here. If CoC would be to start a new thread then please comment and I will do so. Thanks. |
For people running into the above issues, here are few things I found that may help. As of today 6/24/24, SAM doesn't seem to support deployment of additional files that can be referenced through environment variables. So while I could get the local testing to work with absolute path to the file, SAM deploy doesn't include that credential file to deploy and if it does I don't know how/where. Feature request for this and additional details can be found here. To make it work in production unforutnately I had to include the credentials in the code itself. There might be other solutions through CDK or Key management store that I haven't explored. If people know how that can be used here please feel free to comment. Otherwise this issue can be closed. |
If these additional files are in the Please let us know if that helps with your deployment file problem. |
Thank you @mndeveci. I won't be able to test this for few weeks and since the Dev configuration setup, requiring full path to find the file, is different from prod setup that can take file in the same directory under I was going to close the issue with this comment but leaving it open in case you want to add further to it. Please feel free to close it out. Thank you for your responses. |
Description:
I did a sam init for out of the box Typescript Hello world sample. Runs fine when invoked locally but when I try to step into it through VS Debug I get the error below
Steps to reproduce:
npm i
sam build
sam local invoke
runs fine and gives the hello world messageObserved result:
Get the error above. Not sure what debug flag to set here since it is invoked through VS Code
Expected result:
The function is invoked and get to the breakpoint in lambdahandler
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
I am on Mac M1 Sonoma 14.5, SAM CLI, version 1.118.0, aws-cli/2.16.8 Python/3.11.8 Darwin/23.5.0 exe/x86_64
Visual Studio Code version 1.90.1
sam --version
: SAM CLI, version 1.118.0{
"version": "1.118.0",
"system": {
"python": "3.8.13",
"os": "macOS-14.5-arm64-arm-64bit"
},
"additional_dependencies": {
"docker_engine": "26.1.1",
"aws_cdk": "Not available",
"terraform": "Not available"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
The text was updated successfully, but these errors were encountered: