Cannot debug serverless application in Visual Studio Code

前端 未结 4 1342
梦如初夏
梦如初夏 2021-01-01 21:18

I have tried to debug serverless application developed using serverless framework in VS code. I have followed this article.

But when I trying to debug the code I\'m

4条回答
  •  庸人自扰
    2021-01-01 21:47

    Update for 2020:

    Do what the other guides state and setup your project with a launch.json file.

    The problem I had was that the supposed file "program": "${workspaceRoot}/node_modules/.bin/sls" threw an error.

    I changed it to "${workspaceRoot}/node_modules/serverless/bin/serverless" and it worked. Here's the full file:

    .vscode/launch.json:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "Serverless debug",
                "program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
                "args": [
                    "invoke",
                    "local",
                    "-f",
                    "hello",
                    "--data",
                    "{}"
                ]
            }
        ]
    }
    

    Be aware that the argument hello is the name of the function I want to debug. I think the intended use case must be that you change that file name for whatever function you want to invoke. Maybe someone could create a VSCode plugin to do this?

提交回复
热议问题