DEV Community

Discussion on: 5 Steps to debugging Next.js/Node.js from VSCode or Chrome DevTools

Collapse
 
tettoffensive profile image
Stuart Tett

I'm constantly having this issue with debugging Next.js API routes. Often I can't place breakpoints in vscode, or if I do it breaks at some totally random spot (sometimes it will open the correct transpiled file and then I can just move the breakpoint to where it should be).

The only chance I have is to stop my server, restart vscode, blow away the the .next directory, and restart. But as soon as I change some code, I have to do it all over again.

I feel like there must be some trick to it, otherwise, I feel like i'd see more complaints about it.

{
      "type": "node",
      "request": "attach",
      "name": "Attach to Program",
      "skipFiles": [
        "<node_internals>/**"
      ],      
      "port": 9229
    },
"dev": "NODE_OPTIONS='--inspect' next dev",