Breakpoints not being hit when debugging Serverles

2019-05-14 05:05发布

问题:

None of my breakpoints are active when debugging my serverless based application in VSCode.

launch.json

{
  "configurations": [
    {
      "console": "integratedTerminal",
      "cwd": "${workspaceRoot}",
      "name": "Debug",
     "port": 5858,
      "request": "launch",
      "runtimeArgs": [
        "run-script",
        "vscode:debug"
      ],
      "runtimeExecutable": "npm",
      "type": "node"
    }
  ],
  "version": "0.2.0"
}

My package.json

...
"scripts": {
  ...      
  "vscode:debug": "export SLS_DEBUG=* && node --inspect=5858 --debug-brk --nolazy ./node_modules/.bin/serverless invoke local -s local -f customerAlexa -p ./test/requests/FindAgent-First-GoodZip.json"
},
....

When I choose Start Debugging from the menu, all the red breakpoints go grey and the program just executes without stopping on the breakpoints.

I am running Node 6.11.2, Serverless 1.23.0 on a Mac. Thanks all.

回答1:

Here is my launch.json which allows me to use breakpoints.

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "program": "${workspaceRoot}/node_modules/.bin/serverless",
  "args": [
    "offline",
    "start",
    "--skipCacheInvalidation"
  ],
  "env": {
    "NODE_ENV": "development"
  }
}

I am using the serverless-offline to run locally. I also am using webpack and babel. The skipCacheInvalidation is for that.

I hope this points you in the right direction.