Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node Debug serverless offline using vscode

I am using VS Code for development of AWS Lambda functions, I started using the serverless framework and the serverless offline library but, I am unable to use VS Code's debug mode to locally debug the code.

I am referring many sites, Following is one of them: https://medium.com/@OneMuppet_/debugging-lambada-functions-locally-in-vscode-with-actual-break-points-deee6235f590

My project structure is as follows:

enter image description here

Package.json:

enter image description here

launch.json:

enter image description here

I get the following error when I start debug:

enter image description here

Can someone please guide, with the correct configuration?

like image 700
Ani Avatar asked Apr 29 '19 04:04

Ani


1 Answers

in the package.json add debug script:

"scripts": {
.......
    "debug": "node --inspect node_modules/serverless/bin/serverless offline -s dev",
.........
}

VS code lunch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "name": "Serverless",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run",
        "debug"
      ],
      "port": 9229
    }
  ]
}

Then start debugging from VS code

like image 82
mfe Avatar answered Sep 20 '22 13:09

mfe