Cannot debug serverless application in Visual Studio Code

前端 未结 4 1337
梦如初夏
梦如初夏 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 22:04

    I attempted to follow the same article, and experienced the same error. Adding outFiles didn't help, although it did change my error message to:

    Cannot launch program 'd:\\node_modules\.bin\sls' because corresponding JavaScript cannot be found.
    

    I can't explain why VSCode has a problem with the executable in node_modules/.bin, but if I point at node_modules/serverless/bin instead, things work as expected:

    "program": "${workspaceFolder}\\node_modules\\serverless\\bin\\serverless",
    

    Here is my full working configuration, where my test event JSON exists in sample-event.json in the project root:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "Debug Lambda",
                "program": "${workspaceFolder}/node_modules/serverless/bin/serverless",
                "args": [
                    "invoke",
                    "local",
                    "-f",
                    "",
                    "--data",
                    "{}" // You can use this argument to pass data to the function to help with the debug
                ]
            }
        ]
    }
    

    Using Serverless ^1.26.1, Node 8.9.4 LTS, VSCode 1.20.1

提交回复
热议问题