Если вы используете Windows, обновите vscode launch.json и package.json, как показано ниже:
// launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Serverless",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"debug"
],
"outFiles": [
"${workspaceFolder}/handler.js"
],
"port": 9229,
"sourceMaps": true
}
]
}
// package.json
....
"scripts": {
"debug": "SET SLS_DEBUG=* && node --inspect %USERPROFILE%\\AppData\\Roaming\\npm\\node_modules\\serverless\\bin\\serverless offline -s dev"
}
Если в linux ваш сценарий отладки будет:
// package.json
....
"scripts": {
"debug": "export SLS_DEBUG=* && node --inspect /usr/local/bin/serverless offline -s dev"
}