Express Node.js不起作用 [英] Express Node.js doesn't work

查看:158
本文介绍了Express Node.js不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ubuntu 12.04上安装了express4以及node.js,npm和express-generator,并使用以下命令创建了一个应用程序:

I installed express 4 along with node.js,npm and express-generator on my ubuntu 12.04 and created an app using the following commands:

express test --hogan -c less
cd test && npm install
node app.js

现在我应该得到的是快速服务器运行端口3000,但是该命令只是执行并且不会留下任何消息或错误。所以我不知道哪个端口正在运行,或者它是否正在运行。有人知道发生了什么问题吗?感谢提前。

Now what I should get is "Express server running on port 3000" but instead the command simply executes and doesn't leave any message or error. So I have no idea of which port express is running on or whether or not it is running at all. So does anyone know what's going wrong in it? Thanks in advance.

推荐答案

新的快递生成器不添加 app.listen 语句在自动生成的app.js文件中。这可能是一个bug?你可以做的是添加如

The new express generator does not add app.listen statement in the auto generated app.js file. It could be a bug? What you can do is add a statement like

 app.listen(3000, function () {
console.log("express has started on port 3000");
});

这将指示express在3000端口上侦听,并在控制台上打印一个有用的消息。

This will instruct express to listen on port 3000 and print out a helpful message on the console as well.

这篇关于Express Node.js不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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