I’m trying to run netlify functions in the vscode debugger.
I have a very simple hello world netlify function from this tutorial. I’m using netlify-lambda to run the function locally.
exports.handler = async event => {
const subject = event.queryStringParameters.name || 'World';
debugger;
console.log(event);
return {
statusCode: 200,
body: `Hello ${subject}!`
};
};
I have read the debugging section of the netlify-lambda docs but it’s not clear to me that it’s possible for the debugger to connect to the process, it only mentions debug logging.
I tried:
npx --node-arg=--inspect-brk=$DEBUG_PORT --node-arg=--nolazy netlify-lambda serve ./lib/functions
node --nolazy --inspect-brk=$DEBUG_PORT ./node_modules/.bin/netlify-lambda serve ./lib/functions
In both these cases the server starts and the logs say the debugger has connected but when I load the function in the browser though it runs the code the debugger does not stop. I also tried adding a ‘debugger’ statement in the function, but that did nothing.
Is it possible to run the functions in the vscode debugger, if so how?