Skip to content

KyleMit/netlify-func-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo Repo for Debugging Netlify Functions in VS Code

See this thread in stack overflow for more details

Debug Netlify Functions in VS Code


I'm trying to set a breakpoint inside of a netlify function that is executed via netlify dev with the following setup:

Setup

Install Netlify-CLI

npm install netlify-cli -g

netlify.toml

[build]
  functions = "functions/"

functions/hello.js

exports.handler = async(event, context) => {
    let output = `Hello, ${event.queryStringParameters.name}`
    return { statusCode: 200, body: output};
}

Here's a sample project with the setup

Run

You should be able to run normally via netlify dev

netlify dev screenshot

Which will expose the function at the following address:

Debugging Attempts

Launch.config

In VSCode, you should be able to setup debugging with a launch.config. I've tried the following configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}\\node_modules\\.bin\\netlify",
      "args": ["dev"]
    }
  ]
}

But I get the following error:

C:\Program Files\nodejs\node.exe .\node_modules\.bin\netlify dev
Uncaught c:\Users\kylemit\Documents\code\netlify-func\node_modules\.bin\netlify:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
<node_internals>/internal/modules/cjs/loader.js:991
Process exited with code 1

Node --inspect

There are lots of examples that leverage the --inspect switch` for node, but I can't figure out how to get that to work with VS Code Breakpoints.

Other Threads

About

Demo Repo for Debugging Netlify Functions in VS Code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published