【发布时间】:2017-04-24 23:07:57
【问题描述】:
我之前没有使用过Node,但是已经设置了一个Apache localhost。
在我的目录中,我有 index.js 读取
var app = require('express')();
var http = require('http').Server(app);
app.get('/', function(req, res){
res.send('<h1>Hello world</h1>');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
还有一个需要 Express.js 的 package.json。
在命令行中,我 cd 进入工作区并运行 node index.js。但它不会打开服务器,而是会引发此错误。
需要做些什么来产生一个在端口 3000 上侦听的本地服务器? Node版本是6.7.0,express是4.15.2。在 Windows 10 上运行。
【问题讨论】:
标签: javascript node.js server