如何调试自耕农应用程序? [英] How to debug a yeoman application?

查看:115
本文介绍了如何调试自耕农应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用服务器端语言开发Web应用程序的背景的/平台,如使用Java,Python / Django和PHP的,我开始学习的Node.js和自耕农。我认为能够调试服务器端code,以提高code质量至关重要。节点支持通过节点检查和--debug选项调试。但是,如果一个应用程序正在使用一台发电机创造出来的自耕农,说AngularJS,并使用咕噜推出,有一个简单的方法,使调试?

也许一个更高层次的问题,我首先要问的是:如果自耕农促进(如刊登在教程)AngularJS,这是一个客户端的MVC框架,那么广大code将从浏览器,而不是从节点上运行。这就是为什么服务器端调试并不重要,任何更多的理由自耕农,因此没有记录?


解决方案

我开发一个yemoan角fullstack应用。我调试服务器端节点的js应用code如下:


  1. 节点检查。

  2. 修改应用程序Gruntfile.js'来设置调试为真为前preSS服务器


   前preSS:{
     开发:{
      选项​​:{
       脚本:服务器/ app.js,
       调试:真
      }
     }
    }

<醇开始=3>
  • 运行咕噜启动应用程序服务。

  • 在一个单独的终端运行节点检查

  • 开启镀铬并导航到 http://127.0.0.1:8080/debug?port=5858 。 (如果你看到咕噜控制台,你会看到节点调试器是在端口5858)。

  • 现在,你应该能够把断点和调试服务器应用程序code。你可以把调试语句在code,迫使节点在这一点上突破,等待你的检查。

  • 注意:
    节点检查--no- preLOAD加载节点检查速度更快。

    Coming from the background of developing web apps using server-side languages/platforms such as java, python/django and php, I am starting to learn Node.js and yeoman. I consider being able to debug server-side code essential in order to improve code quality. Node supports debugging via node-inspector and --debug option. But if an application is created out of yeoman using a generator, say AngularJS, and launched using grunt, is there an easy way to enable debugging?

    Perhaps a higher level question I should first ask is: If yeoman promotes (as featured in tutorial) AngularJS, which is a client-side MVC framework, then majority of code will run from browser rather than from Node. Is that the reason why server-side debugging is not important any more to yeoman and therefore not documented?

    解决方案

    I am developing a yemoan angular-fullstack application. I debug the server side node js application code as follows;

    1. Install node-inspector.
    2. Modify the application 'Gruntfile.js' to set debug as 'true' for express server

    express: { dev: { options: { script: 'server/app.js', debug: true } } }

    1. Start the application by running grunt serve.
    2. In a separate terminal run node-inspector.
    3. Open chrome and navigate to http://127.0.0.1:8080/debug?port=5858. (If you see the grunt console, you would see the node debugger is on port 5858).
    4. Now you should be able to put breakpoints and debug in your server application code. You could place debugger statement in your code to force node to break at that point and wait for your inspection.

    Note: node-inspector --no-preload loads the node inspector quicker.

    这篇关于如何调试自耕农应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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