如何使用Visual Studio 2013和Node Tools NTVS调试node.js应用程序 [英] How to debug node.js application with Visual Studio 2013 and Node Tools NTVS
问题描述
我已将一个现有的node.js + express项目移动到VS,因为我现在喜欢使用JetBrains的IDE(多年使用VS,只能浏览到Webstorm)。
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).
我使用NTVS新项目 - 从现有的来源,所有文件都被成功导入。
I used NTVS new project->from existing sources and all files were imported successfully.
之后,我打开了项目的项目设置并设置了node.exe参数bin\www,启动文件为快递。
Afterwards, I opened the project settings of my project and set the node.exe arguments to bin\www, startup file for express.
当我按F5(调试)我得到console.log消息我已经放入www和app.js文件在打开的命令提示符,它看起来像服务器正在运行(无法确认,我想调试,如果一切正常),但VS调试器直接退出,它也不会打开任何页面在浏览器我选择进行调试。
我的节点应用程序实际上是一个REST webservice,所以我想测试不同的参数不同的URL。
My node app actually is a REST webservice, so I want to test different URLs with different parameters.
此外,我无法访问我指定的端口的应用程序,虽然当我直接即使命令提示符仍然打开,可以从node.exe启动它。
Also, I cannot access the app on the port I specified, though when I directly start it from node.exe I can, even though the command prompt is still open.
(已安装NTVS和WebEssentials - 某些操作需要很长时间,但是我认为NTVS仍然是一个早期版本。)
(I have NTVS and WebEssentials installed - some operations take a long long time, but I attribute this to NTVS being still an early version.)
问题: Visual Studio调试器如何保持连接到node.js应用程序,所以我可以使用断点并使用任何浏览器来连接和测试不同的URL?(即使是在启动时打印的console.log中的断点也不会被触发。)
Question: how does the Visual Studio debugger stay connected to the node.js application so I can use breakpoints and use any browser then to connect and test different URLs? (Even a breakpoint put on the console.log that gets printed during startup is not being triggered.)
推荐答案
对于所有要求接收的人,搜索者都会发现....
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..)
喜欢调试具有VS的node.js服务器的种类。
Kind of nice to debug node.js server with VS..
希望这有助于某人
编辑:node.ex的参数e可以很难在图像中读取。它必须是
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.
这篇关于如何使用Visual Studio 2013和Node Tools NTVS调试node.js应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!