As I type --
node server
I get the error as given in the title after these lines:
E:\Nodejs_chat_app\server.js:7
var port = Number(process.evn.PORT) || 3000;
以下是在server.js文件中编写的代码片段 -
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
users = [];
connections = [];
var port = Number(process.evn.PORT) || 8888;
server.listen(port);
console.log('server running');
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
答案 0 :(得分:3)
这是一个错字,它应该是:uint3 groupID : SV_GroupID
,而不是process.env.PORT
。
答案 1 :(得分:1)
将命令更改为PORT=3000 node server
以设置process.env.PORT
。或者更改您的代码以在默认端口中运行。
var port = Number(process.env.PORT|| 8888);