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 getting an error from VS code as below.
Cannot launch program 'g:\Projects\Serverless1\node_modules.bin\sls'; setting the 'outDir or outFiles' attribute might help.
sls command file already exists in the folder and following are the launch.json file settings
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"protocol": "inspector",
"name": "run hello function",
"program": "${workspaceRoot}\\node_modules\\.bin\\sls",
"args": [
"invoke",
"local",
"-f",
"hello",
"--data",
"{}"
]
}
]
Please help me to fix this issue.
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:\<path>\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",
"<function-name>",
"--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