Reputation: 11
I'm using AWS SAM with NODEJS16 runtime selecting the 2 - Hello World Example TypeScript template (image for all selected options) .
And then running
sam local start-api
for local testing.
I'm getting the following error when entering to http://127.0.0.1:3000/hello:
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:951:17)"," at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:976:21)"," at async start (file:///var/runtime/index.mjs:1137:23)"," at async file:///var/runtime/index.mjs:1143:1"]}
BUT, if I select the 1 - Hello World Example template, it is working fine, do I need to do something additional to be working with TypeScript template? I also tried with node14 but still getting the same error for TypeScript template.
Additionally, if I deploy the lambda function (2 - Hello World Example TypeScript template) is working fine in AWS (sam build/sam deploy --guided
), but I need to run it locally...
I'm not sure if it matters but I'm using MacBook with M1 processor.
Upvotes: 1
Views: 281
Reputation: 1
Before starting the local server, you need to run sam build
in order to download, initialize and build the TS code.
You can see this in the AWS SAM docs
Upvotes: 0