如何调试Node.js

可以直接在vs code里面调试

在debug侧边栏里,创建一个launch.json,选择node.js。然后会自动生成

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}\\index.js"
        }
    ]
}

 

Debugging Node.js with Chrome DevTools

https://nodejs.org/en/docs/guides/debugging-getting-started/

1.

PS C:\Users\clu\Documents\NodeApp\Test> node --inspect .\app.js
Debugger listening on ws://127.0.0.1:9229/34c03922-857b-4e6d-82cf-30dbf27a76ff
For help, see: https://nodejs.org/en/docs/inspector
Server running at http://127.0.0.1:3000/

 

2.在Chrome浏览器中打开about:inspect

 

3.打开 Click the Open dedicated DevTools for Node link.

 

 

在vs2017中调试

https://github.com/Microsoft/nodejstools/wiki/Debugging

创建Node.js项目,https://github.com/Microsoft/nodejstools/wiki/Projects

debug设置,https://github.com/Microsoft/nodejstools/wiki/Debugging#debugging-options

 

 

Developer Tools in Chrome(Chrome Extension)

https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj

 

posted @ 2018-05-29 12:51  ChuckLu  阅读(874)  评论(0编辑  收藏  举报