node.js - 如何检查 Node express中间件上变量的内容(调试)

标签 node.js express

我想知道在哪里以及如何看到变量给出特定内容的时刻以及哪些内容可以包含,需要使用 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;
        }
      },

please, note that question is different from my other question Debugging nodejs with atom IDE

最佳答案

解决了!

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

解决方案是:

  1. 在之前使用 npm 安装的终端中启动 node-inspector。

    Node 检查器

  2. 启动 Node 服务器应用程序。

    Node --调试www

  3. 在 Chrome 中打开 http://127.0.0.1:8080/?port=5858请参阅 Node 检查器和 localhost:3000 (默认)

  4. 现在,在检查器中在行号上设置断点,单击蓝色的“播放”按钮并去激发谁触发断点。

  5. 在检查器中,浏览器将保持加载状态,如果您切换到运行 Node 检查器的 Chrome 选项卡,您可以将光标移动到 reqres 上方,并显示一个 IncommingMessage 对话框,其中包含 reqres 或您使用的任何内容的内容。

This is similar to the related post but not the same, cause here shows specific information for someone who can being searching solution for the same question.

关于node.js - 如何检查 Node express中间件上变量的内容(调试),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36926564/

相关文章:

node.js - 控制台未打开时无法加载资源:net::ERR_EMPTY_RESPONSE

ajax - nodejs : Ajax vs Socket. IO,优点和缺点

javascript - 如何在 Node.js 中添加 promise.all Sequelize findOrCreate 循环?

mongodb - sails 船 : automatically create composite unique index (mongodb)

ios - Swift POST 请求以错误的格式将正文传递给 node.js/express 应用程序

angularjs - 使用 Angular 和 Express 登录用户的正确方法是什么?

javascript - 所有脚本和页面加载完成后如何获取所有html数据? ( puppeteer 师)

sql - 使用 Node.js 连接表的 GraphQL 查询

javascript - 发送错误后无法设置 header 。我没有调用 render()/json() 两次

node.js - 如果在多个项目中使用数据库模型文件夹,如何集中?