How to debug node.js application with Visual Studio 2013 and Node Tools NTVS

前端 未结 3 1961
不思量自难忘°
不思量自难忘° 2020-12-24 15:28

I have moved an existing node.js + express project to VS because I prefer the IDE over JetBrains for now (used VS for years, only peeked into Webstorm).

I used NTVS

相关标签:
3条回答
  • 2020-12-24 16:07

    Not so much knowledge on expressjs but with a recent release of NTVS 1.0 Alpha, I did find it supports remote debugging which can be also used to debug nodejs app running locally - anyway haven't tried if it works with nodejs app + expressjs but it should.

    I followed the step in this video https://youtu.be/-ir9ZB8lUg4 which is

    1. Run your nodejs with node.exe RemoteDebug.js <your_javascript_file>.
      RemoteDebug.js has come when you install NTVS.
    2. In Visual Studio, select Debug > Attach to Process
    3. Select Node.js remote debugging for Transport
    4. Enter localhost:5859 for Qualifier
    5. Click Attach

    This will put Visual Studio in debugging mode which you can set a breakpoint, do step-in/step-out, very same experience when you use VS to debug .NET app.

    0 讨论(0)
  • 2020-12-24 16:20

    Its pretty straight forward with NTVS, you can download required version for your windows from github here

    Once you install NTVS, NodeJS project templates will be added

    Now, Goto File->New project -> Basic NodeJS Express 3 application (it will be available in javascript project templates)

    Now just goto debug and select Start Debugging, add breakpoints where ever required and you can start debugging

    0 讨论(0)
  • 2020-12-24 16:26

    For everyone who asks receives, and the one who searches finds....

    (and yes, I did spend a long time searching and trying before posting here..)

    Settings

    Kind of nice to debug node.js server with VS..

    hope this helps someone

    Edit: The arguments to node.exe can be hard to read in the image. It must be

     --debug=<portno>
    

    that is with two dashes (and not just one) to specify the debug port.

    0 讨论(0)
提交回复
热议问题