Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging nextjs app in chrome and vscode

I have inserted this snippet in my launch.json file. It always opens up chrome and is stuck at about:blank, and then vscode gives the timeout error. I built this launch.json file by following the steps here. https://github.com/Microsoft/vscode-recipes/tree/master/Next-js and modified it to run for chrome canary.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome Canary",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000/",
            "runtimeExecutable": "C:/Users/myusername/AppData/Local/Google/Chrome SxS/Application/chrome.exe",
            "webRoot": "${workspaceFolder}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Next: Node",
            "runtimeExecutable": "next",
            "runtimeArgs": [
                "--inspect"
            ],
            "port": 9229,
            "console": "integratedTerminal"
        }
    ],
    "compounds": [
        {
            "name": "Next: Full",
            "configurations": [
                "Next: Node",
                "Chrome Canary"
            ]
        }
    ]
}
like image 497
Aijaz Avatar asked Feb 19 '19 18:02

Aijaz


1 Answers

Debug Nextjs program without custom server, use the configuration:

{
  "type": "node",
  "request": "launch",
  "name": "Launch via NPM",
  "runtimeExecutable": "${workspaceFolder}\\node_modules\\.bin\\next",
  "port": 9229,
  "env": {
    "NODE_OPTIONS": "--inspect"
  }
}

Debug Nextjs program with custom server, use the configuration:

{
  "type": "node",
  "request": "launch",
  "name": "Next: Node",
  "program": "${workspaceFolder}/server.js",
  "runtimeArgs": [
      "--inspect"
  ],
  "port": 9229,
  "console": "integratedTerminal"
}
like image 75
695954085 Avatar answered Sep 29 '22 15:09

695954085