aws / aws/aws-toolkit-vscode

Local Lambda debug (typescript): error: Cannot find module 'app'

Open
#3,833 8 comments 0 reactions 0 assignees View on GitHub
guidance javascript lambda language:node language:typescript sam
Dominant language
TypeScript
Stars
2k
Forks
807
Avg merge
10h 12m
Merged PRs (30d)
7

Description

## System details (run the `AWS: About Toolkit` command)

- OS: Windows 10
- Visual Studio Code version: 1.82.2
- AWS Toolkit version: v1.89.0

## Question

I'm trying to debug a node lambda through AWS Toolkit.

I've used sam init to generate the default hello-world typescript project.

I've gone to the lambdaHandler and selected AWS: Add Debug Configuration.

I then have run the debugger using the generated launch config.

I then get the error reported in the screen shots and my break point is never hit.

Any idea what I am doing wrong / missed?

Thanks

```
Debugger attached.
2023-09-14T23:02:07.592Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'app'\nRequire stack:\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module 'app'","Require stack:","- /var/runtime/index.mjs"," at _loadUserApp (file:///var/runtime/index.mjs:1061:17)"," at async Object.load (file:///var/runtime/index.mjs:1093:21)"," at async start (file:///var/runtime/index.mjs:1256:23)"," at async file:///var/runtime/index.mjs:1262:1"]}
Waiting for the debugger to disconnect...
14 Sep 2023 23:02:07,657 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 129 InvokeID=
Debugger listening on ws://0.0.0.0:5858/461ef53a-cace-487d-834f-eafc5243466f
For help, see: https://nodejs.org/en/docs/inspector
```

![image](https://github.com/aws/aws-toolkit-vscode/assets/56564334/bb06b927-ddd0-424e-8f81-f566fb927ab8)

![image](https://github.com/aws/aws-toolkit-vscode/assets/56564334/aab0b019-fa12-4056-b24f-bd08cea1be11)

![image](https://github.com/aws/aws-toolkit-vscode/assets/56564334/79c03d7d-e899-4fcd-8174-a23e15c5be8e)

Contributor guide

Open the contributing guide

Research direction

Start with the SAM-generated hello-world TypeScript project, the generated launch configuration from AWS: Add Debug Configuration, and the reported Cannot find module 'app' log. Compare the configured Lambda handler and local module resolution, then verify the debugger starts successfully and reaches the breakpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js, typescript, vscode
Domain
cloud, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.