1

无法使用 Nodeclipse 在 Eclipse 中运行简单的 Node Express 应用程序。获取“Node.js 进程”的控制台消息

全新安装。有什么建议么

New>> 右键单击Project​​ App.jsNode ExpressRun As Node Application

Eclipse Version for JAVA and Reporting: Luna Service Release 1 (4.4.1)
Nodeclipse Core and Node.js 0.17.0.201409260936
MAC OSX 10.10.1 (14B25) 64bit
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
4

1 回答 1

1

当 Nodeclipse 创建一个新的 Express 项目(express 版本 >4.0)时,它会错过启动服务器,因此它会监听某个端口(这就是它完成而没有任何错误的原因)。

为了让它工作,您应该在 app.js 文件的末尾添加:

app.listen(3000, function () {
  console.log('App listening on port 3000!');
});

在之前的 express 版本中,等价于:

http.createServer(app).listen(app.get('port'), function(){
   console.log('Express server listening on port ' + app.get('port'));
});
于 2016-05-06T14:44:44.980 回答