VSCode - 调试器没有在邮递员请求中遇到断点

时间:2018-02-15 15:44:36

标签: node.js visual-studio-code postman

我正在构建一个express.js应用程序,我正在使用Postman进行测试。到目前为止我还没有调试过,但我只是试图设置它并遇到一些问题。

我关注this tutorial,但它并不适合我,因为教程的最终结果显示它应该。

我自己构建了一个launch.json文件,其中的配置可以使用nodemon处理运行...

"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "nodemon",
        "runtimeExecutable": "nodemon",
        "program": "${workspaceFolder}/app.js",
        "restart": true,
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen"
    },
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceFolder}\\bin\\www"
    }
]

然后我启动了调试器并在终端中获得了以下输出......

  

C:\ Users \ User \ AppData \ Roaming \ npm \ nodemon.cmd --inspect = 35939 --debug-brk app.js

     

[nodemon] 1.14.11

     

[nodemon]随时重启,请输入rs

     

[nodemon]正在观看:

     

[nodemon]从node --inspect=35939 --debug-brk app.js开始

     

调试器正在侦听   WS://127.0.0.1:35939 / fca1b410-e096-4189-a5b2-bf266755e89e

     

如需帮助,请参阅https://nodejs.org/en/docs/inspector

     

附加调试器。

     

(node:24832)[DEP0062]弃用警告:node --inspect --debug-brk已弃用。请改用node --inspect-brk

为了测试它,我在app.js文件的第一行放了一个断点。突破点被成功击中。

我进入路由器文件并在post方法中放置了一个断点,我需要调试...

//POST New Trip page//
router.post('/newtrip', function (req, res) {
    return tripCtrl.create(req, res); <---- BP on this line
});

然后我运行了我用来测试此方法的Postman请求:

  

(POST)http://localhost:3000/newtrip

我完全期待我的新断点被击中,但断点并没有被击中,我的调试器控制台或终端没有输出。我只有Postman返回&#39;无法得到任何回复&#39;。

我很好,真的迷失了去哪儿。谁能想到这里可能有什么问题呢?

这是我项目的文件结构:

project file structure

谢谢, 马克

1 个答案:

答案 0 :(得分:0)

这是基于start命令在vscode中调试所需的lanuch.json的最低配置。尝试使用此更新进行调试。

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/bin/www"
        }
    ]
}
相关问题