学习node.js/express.js:bin/www处理了什么? [英] Learning node.js/express.js: What's the deal with bin/www?

查看:115
本文介绍了学习node.js/express.js:bin/www处理了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过Express.js的教程,例如,该教程从头开始有自己的app.js文件,并使用快速生成器放弃.

I've seen tutorials for express.js such as this which starts from scratch with their own app.js file and forgoes using the express generator.

我的问题:对于试图掌握如何使用这些工具并制作基本Web应用程序的初学者,我应该关注bin/www还是应该在app.js中定义端口?

My question: for beginner who's trying to grasp just how to use these tools and make a basic web application should I be concerned with bin/www or should I just be defining the port within app.js?

我目前在bin/www中唯一了解的功能是设置端口. Express生成器是否只是在边缘盒功能上肿了,而这对于初学者来说太多了?

The only functionality I currently understand in bin/www is setting the port. Is the express generator simply bloated with edge case functionality which is too much for a beginner?

推荐答案

这是原因,由快递维护人员简洁地指出:

Here is the reason, stated succinctly by an express maintainer:

因此,您可以从外部文件中请求('./app')并获得快递 不在任何端口上监听的应用程序(请考虑单元测试等).

So you can require('./app') from external files and get the express app that is not listening on any port (think unit tests and the like).

这篇关于学习node.js/express.js:bin/www处理了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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