在Chrome和vscode中调试nextjs应用

JavaScript React.js

宝儿A梅

2020-03-23

我已将此片段插入launch.json文件中。它总是打开chrome,并停留在about:blank,然后v​​scode给出超时错误。我按照此处的步骤构建了launch.json文件。 https://github.com/Microsoft/vscode-recipes/tree/master/Next-js并对其进行了修改,以针对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"
            ]
        }
    ]
}

第2943篇《在Chrome和vscode中调试nextjs应用》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
2020.03.23

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"
}

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android