【问题标题】:Eclipse node.js project is not stopping on breakpointsEclipse node.js 项目没有在断点处停止
【发布时间】:2014-03-07 23:32:10
【问题描述】:

我正在使用新安装的 eclipse 实例使用 node.js (here) 玩 Node.js 和 eclipse。我有过 eclipse 的经验,但这是为此目的的新安装。我已经使用 Node.js 有一段时间了,但我想看看 eclipse 可以增加我的头痛(或者希望减轻(一些?)它们!)。 节点--版本 v0.10.22 Eclipse 版本是版本:Kepler Service Release 2 Build id:20140224-0627。

好的,所以我使用 New > Other.. > Nodeclipse > Node.js Express Project 创建了一个新项目。给它命名为 Hello World 并采用默认值。我更新了 index.js 文件,添加了一些有趣的东西来添加断点:

exports.index = function(req, res){
  res.render('index', { title: 'Express' });
  console.log( "here" );
  var i=45;
  i = i+3;
  console.log( i );
};

我在 i = i+3 行上放了一个断点。我试过运行,运行方式>节点应用程序,当我从浏览器点击“mylclhost:3000”时,它并没有在我的断点处停止。如果我执行 Debug As > Nodejs Application,它会显示一个带有蓝色 chrome favicon 的新面板(类似于 this guy 状态发生的情况),点击 mylclhost:3000 会导致 404,所以我点击 F8 继续和 mylclhost:3000按预期工作,但没有断点命中。

这是我在 Project Explorer > 右键单击​​ app.js > Debug As > Node Application 之后的 Nodeclipse 控制台输出: 节点 --debug-brk=5858 C:\Users\person\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js C:\Users\person\workspace\HelloWorld\app.js --tea-pot-模式

这是我在第一个断点(Notice that Nodeclipse by default enters step-by-step debugging mode from very first line)后按 F8 继续后的正常控制台输出:

debugger listening on port 5858
21 Mar 09:58:38 - [33m[nodemon] v1.0.15[39m
21 Mar 09:58:38 - [33m[nodemon] to restart at any time, enter `rs`[39m
21 Mar 09:58:38 - [33m[nodemon] watching: *.*[39m
21 Mar 09:58:38 - [32m[nodemon] starting `node C:\Users\person\workspace\HelloWorld\app.js --tea-pot-mode`[39m
Express server listening on port 3000

然后我将浏览器指向 lclhost:3000 并获得成功页面,正常控制台报告:

.... other stuff....
Express server listening on port 3000
[90mGET / [36m304 [90m234ms[0m
here
48
[90mGET /stylesheets/style.css [36m304 [90m4ms[0m

带断点的相关代码(标记为*):

exports.index = function(req, res){
  res.render('index', { title: 'Express' });

  console.log( "here" );
  var i=45;
 *i = i+3;

  console.log( i );

};

您可以看到它在控制台中打印“48”并完全跳过断点。

就像我说的,这是一个新安装,所以上面链接的帖子并没有真正的帮助。我怀疑这与 Node.js 的异步特性有关,但似乎其他人已经成功地让它工作了。

有什么想法,或者我缺少什么吗?

【问题讨论】:

  • 而不是新建 > 其他.. > Nodeclipse > Node.js Express 项目。切换到节点视角。我也用nodeclipse标签监控SO问题,但它不见了。 nodeclipse.org/#support

标签: eclipse node.js debugging breakpoints nodeclipse


【解决方案1】:

您可以尝试在命令窗口中运行node --debug-brk=5858 app.js,然后在该文件上启动 Eclipse 调试器。这对我有用。我正在使用 Enide Studio 2014。

【讨论】:

    【解决方案2】:

    花时间学习更多东西。

    你好像连http://www.nodeclipse.org主页都没看过,参考如何获得支持 http://www.nodeclipse.org/#support

    Run As > stats Node.js 处于非调试模式,所以它当然不会停止。

    而不是 New > Other.. > Nodeclipse > Node.js Express Project 切换到 Node 透视图。

    另见Nodeclipse debugger ignoring breakpoints

    如果问题仍然存在,请提出问题,再次提供http://www.nodeclipse.org/#support 中提到的信息

    【讨论】:

    • 啊,是的,Run As 明白了。但如前所述,我做了 Debug As 并且它命中了一些随机断点,但忽略了我的其他断点。我确实找到了“节点”透视图,但是当我执行 Run > Debug 时,我被问到“这种启动配置为在挂起时打开 Debug 透视图”,然后我又回到了 Debug 透视图,它似乎有所有如果它会在我的断点处停止,我需要的信息。
    • 好的,所以输入按钮发送评论...注意...我敢肯定这更多的是用户错误而不是错误。我在控制台中没有看到 debug-brk=5858 参数,所以我会四处寻找如何添加它并回发。
    • 帖子已更新。您现在可以在控制台输出中看到 debug-brk。我不知道现在该去哪里?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 1970-01-01
    • 2011-05-22
    • 2021-03-19
    • 2021-12-18
    相关资源
    最近更新 更多