【问题标题】:How can i check the content of variables on the node express middleware (debugging)如何检查节点 express 中间件上的变量内容(调试)
【发布时间】:2016-08-23 22:04:44
【问题描述】:

我想知道我在哪里以及如何查看变量给出特定内容的那一刻以及哪些内容可以具有,需要返回带有console.log('not login'); 的控制台消息,这是我的代码,第一行可以正常工作:

 authenticated : function(req, res){

        if (req.user) {
            res.redirect('/user');
            //res.send(req.user.username);
            console.log('user enter');

        }
        else {

            res.render('account/login.jade', { title: "Usuario o contraseña incorrecta, si no recuerda su clave puede restablecerla más abajo." });
            console.log('not login');
            res.end;
        }
      },

请注意,这个问题与我的其他问题 Debugging nodejs with atom IDE

不同

【问题讨论】:

  • 不知道你在寻求什么帮助。
  • @jfriend00 我也不是 xD
  • 如果你使用nodemon 运行你的node.js 应用程序,你可以看到console.log() 的输出。不知道该怎么做
  • 这是我使用 nodemon 时返回控制台的内容:GET /javascripts/autoload.js 304 4.750 ms - - ::ffff:127.0.0.1 - - [29/Apr/2016:07:35 :51 +0000] "GET /images/Logo.png HTTP/1.1" 304 - "localhost:3000/user/login" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0" GET /images /Logo.png 304 1.271 ms - - 用户输入 ::ffff:127.0.0.1 - - [29/Apr/2016:07:36:05 +0000] "POST /user/login HTTP/1.1" 302 66 "@987654324 @" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0"

标签: node.js express


【解决方案1】:

解决了!

最后,我找到了解决方案,这个视频https://www.youtube.com/watch?v=03qGA-GJXjI&feature=youtu.be 在此威胁debugging node.js with node-inspector 的帮助之后帮助做到了这一点。

解决办法是:

  1. 在您之前使用 npm 安装的终端中启动节点检查器。

    节点检查器

  2. 启动您的节点服务器应用程序。

    节点 --debug www

  3. 在 Chrome 中打开 http://127.0.0.1:8080/?port=5858 以查看节点检查器和 localhost:3000(默认)

  4. 现在,在inspector中设置断点的行号,点击蓝色的“播放”按钮,去挑衅谁触发断点。

  5. 1234563 IncommingMessage 对话框,其内容为 reqres 或您使用的任何内容。

这与相关帖子相似但不一样,因为这里显示了可以为同一问题搜索解决方案的人的特定信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-28
    • 2015-09-22
    • 1970-01-01
    • 2014-10-28
    • 2010-09-11
    • 1970-01-01
    • 2014-07-10
    • 2018-12-25
    相关资源
    最近更新 更多