gpt4 book ai didi

Eclipse Node.js 项目没有在断点处停止

转载 作者:太空宇宙 更新时间:2023-11-03 22:40:12 26 4
gpt4 key购买 nike

我正在使用新安装的 eclipse 实例使用 nodeclipse ( here ) 来玩 Node.js 和 eclipse。我有过使用 Eclipse 的经验,但这是为此目的进行的新安装。我已经使用 Node.js 一段时间了,但我想看看 eclipse 可以增加我的头痛(或者希望缓解(其中一些?)它们!)。 Node --版本v0.10.22Eclipse 版本是版本:Kepler Service Release 2 构建 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 行上放置了一个断点。我尝试过“运行”、“运行方式”>“Node 应用程序”,当我从浏览器中单击“mylclhost:3000”时,它不会在断点处停止。如果我执行“调试为”> Nodejs 应用程序,它会显示一个带有蓝色 Chrome 图标的新面板(类似于 this guy 状态发生的情况),点击 mylclhost:3000 会导致 404,所以我点击 F8 继续,然后点击 mylclhost:3000按预期工作,但没有断点命中。

这是我在 Project Explorer > 右键单击​​ app.js > 调试为 > Node 应用程序后的 Nodeclipse 控制台输出: Node --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 的异步特性有关,但似乎其他人已经成功地使其发挥作用。

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

最佳答案

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

关于Eclipse Node.js 项目没有在断点处停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22262747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com