Closed samshteinman closed 3 months ago
Linked issue: https://github.com/aws/aws-sam-cli/issues/6999
I'm not sure why it's looking for index.mjs
AWS Toolkit currently assumes that any node 20.x project will have a .mjs entrypoint.
Since your example appears to be a typescript project, it may be necessary to build it first. Also using invokeTarget.target = template
may help.
Thanks for your response!
AWS Toolkit currently assumes that any node 20.x project will have a .mjs entrypoint.
I re-created the project and chose node 16, same issue. The template.yaml and the launch configuration both specify nodejs 16
There is no index file specified anywhere, I have an app.ts , the "main" in my package.json specifies "app.js"
Since your example appears to be a typescript project, it may be necessary to build it first.
The project is automatically being built, at least according to the AWS Toolkit output
Also using invokeTarget.target = template may help.
Switching over to template, I see that the function runs successfully, but no breakpoints are being hit.
Pulled down the source code and starting to investigate...
One thing I'm noticing is that when sam build is triggered by the toolkit, the generated InputTemplate appvsctktemplate.yaml does not contain the metadata for ESBuild, is it supposed to? (The default template.yaml in the base-dir contains this information)
Either way, the output code in the temp directory, is all still Typescript, it's never transpiled to Javascript.
If I set breakpoints, and add the metadata manually to the appvsctktemplate.yaml, the esbuild step is triggered by sam build, and the code runs successfully, the error I originally talked about is gone... BUT still no breakpoints being hit.
Skipping the toolkit entirely, if I just call sam local invoke -d 5858 and attach, I still can't get the breakpoints to hit. So looks like issue is outside the toolkit?
Description:
After calling sam init, I cannot run and debug the application.
Breakpoints are not hit and an error is shown
I'm not sure why it's looking for index.mjs The auto-generated aws-toolkit-tsconfig.json contains:
Steps to reproduce:
sam init
Which template source would you like to use? 1 - AWS Quick Start Templates 2 - Custom Template Location Choice: 1
Choose an AWS Quick Start application template 1 - Hello World Example 2 - Data processing 3 - Hello World Example with Powertools for AWS Lambda 4 - Multi-step workflow 5 - Scheduled task 6 - Standalone function 7 - Serverless API 8 - Infrastructure event management 9 - Lambda Response Streaming 10 - Serverless Connector Hello World Example 11 - Multi-step workflow with Connectors 12 - GraphQLApi Hello World Example 13 - Full Stack 14 - Lambda EFS example 15 - DynamoDB Example 16 - Machine Learning Template: 3
Which runtime would you like to use? 1 - dotnet8 2 - dotnet6 3 - java17 4 - java11 5 - java8.al2 6 - nodejs20.x 7 - nodejs18.x 8 - nodejs16.x 9 - python3.9 10 - python3.8 11 - python3.12 12 - python3.11 13 - python3.10 Runtime: 6
Based on your selections, the only Package type available is Zip. We will proceed to selecting the Package type as Zip.
Based on your selections, the only dependency manager available is npm. We will proceed copying the template using npm.
Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: N
Would you like to enable monitoring using CloudWatch Application Insights? For more info, please view https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-application-insights.html [y/N]:
Would you like to set Structured Logging in JSON format on your Lambda functions? [y/N]:
Project name [sam-app]:
Create a launch configuration
Observed result:
Code is not executed Breakpoints are not hit in app.ts An error is shown in the AWS Toolkit OUTPUT console
Expected result:
Breakpoints are hit, code is executed
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
System details (run the
AWS: About Toolkit
command)