Description
Problem
When using the built-in Hello World nodejs Lambda template, invoking the default launch configuration results in a JavaScript ImportModule Error: Error: Cannot find module 'app'
while manually running sam local invoke
in the terminal works fine.
Steps to reproduce the issue
- Create new workspace
- Cmd+P, >AWS: Create Lambda SAM Application
- nodejs20.x (or nodejs22.x)
- arm64
- AWS SAM Hello World
- Select current folder
- return
- Select Run and Debug from the menu and run the default launch configuration
Actual behavior
2024-12-05 01:04:36.659 [info] 2024-12-05T09:04:36.727Z 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:1087:17)"," at async Object.load (file:///var/runtime/index.mjs:1119:21)"," at async start (file:///var/runtime/index.mjs:1282:23)"," at async file:///var/runtime/index.mjs:1288:1"]}
The full log output by Run and Debug is attached: vscode.txt
Expected behavior
The function is invoked locally.
The odd thing is that if I switch to the terminal tab and run cd lambda-nodejs20.x && sam local invoke
, it works as expected and outputs the hello world response sucuessfully. It works just running the sam-cli directly in the terminal, but always fails to find the module when invoked through the vscode launch configuration. I get the same behavior in my actual project, but simplified it down to the built-in hello world template for the purpose of this report.
System details (run AWS: About
and/or Amazon Q: About
)
OS: Darwin arm64 24.1.0
Visual Studio Code extension host: 1.95.3
AWS Toolkit: 3.37.0
node: 20.18.0
electron: 32.2.1