0

I am new to the serverless framework and is trying to debug Serverless (Node js) locally in Visual code using breakpoints.

I referred to some articles but didn't help me out that much.

https://medium.com/@OneMuppet_/debugging-lambada-functions-locally-in-vscode-with-actual-break-points-deee6235f590 https://hackernoon.com/running-and-debugging-aws-lambda-functions-locally-with-the-serverless-framework-and-vs-code-a254e2011010

2
  • 1
    add the problems you encounter specifically. Commented Sep 20, 2018 at 0:09
  • 1
    If all you are trying to debug is your functionality (and not platform related stuff) why not just run some code that sets up the evn variables + input and then invoke the handler? If you DO wish to debug some of the platform related stuff (e.g event loops, context related) i'm not sure it's possible. This might help but i'm not familiar with that aws.amazon.com/about-aws/whats-new/2017/08/… Commented Oct 4, 2018 at 5:15

1 Answer 1

2

finally, I was able to fix the issue, I was missing node path

{
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Debug Local",
        "program": "${workspaceFolder}/node_modules/serverless/bin/serverless",
        "cwd": "${workspaceRoot}",
        "args": [
            "invoke",
            "local",
            "-f",
            "functionname",
            "--path",
            "../test.json", // pass the path of local test event
            "--stage",
            "AWs envrionment name" // eg: dev,stage, prod etc
        ],
        "env": {
            "NODE_PATH": "${cwd}"
        }
    }]
}           
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.