带有Node.js后端的Next.js前端的VSCode调试配置

时间:2019-06-27 11:43:12

标签: node.js debugging npm-scripts vscode-debugger

在我的项目目录中,next.js中有一个前端,而在Node.js中有一个后端,如下所示:

enter image description here

我现在想调试程序,因此后端和前端都必须运行,而且我不知道如何创建顶层项目中具有的corrent debug launch.json配置,以启动和调试两个程序。

{
"version": "0.2.0",
"compounds": [
    {
        "name": "Client+Server",
        "configurations": [ "DCBACKEND", "DCFRONTEND" ]
    }
],
"configurations": [        
    {
        "type": "node",
        "request": "launch",
        "name": "DCBACKEND",
        "cwd" : "${workspaceFolder}\\dcbackend",
        "runtimeExecutable": "npm",
        "runtimeArgs": [
            "run-script", "start"
        ]
    },
    {            
        "type": "node",
        "request": "launch",
        "name": "DCFRONTEND",
        "cwd" : "${workspaceFolder}\\dcfrontend",
        "program": "${workspaceFolder}\\dcfrontend\\pages\\index.js",
        "runtimeExecutable": "next",
        "runtimeArgs": [
            "--inspect"
        ]
    }
]

}

编辑:现在,我收到以下错误:

enter image description here

我后端的启动脚本是:

 "scripts": {
    "start": "node index.js -p 7766"
  },

那么端口可能有问题吗?此外,它在cmd-line中运行另一个脚本进行调试:

C:\Program Files\nodejs\npm.cmd run-script start --inspect-brk=39777 

我不知道与--inspect-brk=39777有什么关系,我是否需要

0 个答案:

没有答案