如何使用 Visual Studio 2013 和 Node Tools NTVS 调试 node.js 应用程序 [英] How to debug node.js application with Visual Studio 2013 and Node Tools NTVS

查看:20
本文介绍了如何使用 Visual Studio 2013 和 Node Tools NTVS 调试 node.js 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将现有的 node.js + express 项目移到了 VS,因为我现在更喜欢 IDE 而不是 JetBrains(使用 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 参数设置为 binwww,express 的启动文件.

Afterwards, I opened the project settings of my project and set the node.exe arguments to binwww, startup file for express.

当我按 F5(调试)时,我在打开的命令提示符中收到我已放入 www 和 app.js 文件的 console.log 消息,看起来服务器正在运行(无法确认,我如果一切正常,想调试),但VS调试器直接再次退出,它也没有在我选择调试的浏览器中打开任何页面.

我的节点应用实际上是一个 REST web 服务,所以我想用不同的参数测试不同的 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.exe 的参数在图像中可能难以读取.应该是

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆