node.js - 用node express创建的默认应用,不能通过浏览器访问?
PHPz
PHPz 2017-04-17 11:22:18
0
3
767

按照github上的quick start一步一步下来,npm start 启动server, 但app.js貌似没有监听任何端口,但是server启动了?通过浏览器访问不了页面,是这样吗?

究竟是哪里有问题?

创建方法就是:

$ express /tmp/foo && cd /tmp/foo

启动服务器是:

$ npm install
$ npm start

更:

正如一楼说的,默认的是3000端口,写在bin/www里,但问题是这里明明debug出了文本,为什么终端窗口里看不到?

var server = app.listen(app.get('port'), function() {
  debug('Express server listening on port ' + server.address().port);
});
PHPz
PHPz

学习是最好的投资!

reply all(3)
刘奇

The listening port of express is set in the /bin/www.js file, and the default is port 3000. Do you have a port added to your browser?

黄舟

Looking at the project generated by express, /bin/wwwrequired the https://github.com/visionmedia/debug module.

The DEBUG environment variable is then used to enable these based on space or comma-delimited names.

You can see all debug information like this:

DEBUG=* npm start

Of course there is also the sentence you expect to see: Express server listening on port 3000

黄舟

Listening 0.0.0.0

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template