question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lambda code not in root (CDK typescript project)

See original GitHub issue

Desktop:

  • OS: Mac
  • VS Code version: 1.52.1
  • AWS Toolkit extension version: 1.18.0

When using cdk, how do you setup a lambda debug where the lambda is not in the root?

{
  "configurations": [
    {
      "type": "aws-sam",
      "request": "direct-invoke",
      "name": "lambda debug",
      "invokeTarget": {
        "target": "code",
        "projectRoot": "",
        "lambdaHandler": "lib/lambdas/helloworld/hello.handler"
      },
      "lambda": {
        "runtime": "nodejs10.x",
        "payload": {},
        "environmentVariables": {}
      }
    }
  ]
}

Debugger attached. 2021-01-30T14:01:55.990Z undefined ERROR Uncaught Exception {“errorType”:“Runtime.ImportModuleError”,“errorMessage”:“Error: Cannot find module ‘hello’”,“stack”:[“Runtime.ImportModuleError: Error: Cannot find module ‘hello’”," at _loadUserApp (/var/runtime/UserFunction.js💯13)“,” at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)“,” at Object.<anonymous> (/var/runtime/index.js:45:30)“,” at Module._compile (internal/modules/cjs/loader.js:775:14)“,” at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)“,” at Module.load (internal/modules/cjs/loader.js:653:32)“,” at tryModuleLoad (internal/modules/cjs/loader.js:593:12)“,” at Function.Module._load (internal/modules/cjs/loader.js:585:3)“,” at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)“,” at startup (internal/bootstrap/node.js:283:19)"]}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
sambarfootcommented, Jun 9, 2021

so I tried the debugger and get this error image

1reaction
justinmk3commented, Sep 22, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-lambda module - AWS Documentation
Code.fromAsset(path.join(__dirname, 'lambda-handler')), });. (Example not in ... referencing the asset directory relatively to our CDK project directory.
Read more >
AWS TypeScript CDK and Lambda - AWS in Plain English
Create a folder in the root of your project (same level as bin and lib) called lambda. Add a file to the lambda...
Read more >
Hello Lambda | AWS CDK Workshop
Lambda handler code # We'll start with the AWS Lambda handler code. Create a directory lambda in the root of your project tree...
Read more >
Lambda can't find modules from outer folders when deployed ...
Problem was CDK not deploying the node_modules folder and other ... the lambda file root path has to be added to the 'code'...
Read more >
@aws-cdk/aws-lambda-nodejs - npm
The NodejsFunction construct creates a Lambda function with automatic transpiling and bundling of TypeScript or Javascript code. This results in smaller Lambda ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found