gpt4 book ai didi

node.js - TypeError:无法读取未定义的属性“PORT”

转载 作者:太空宇宙 更新时间:2023-11-04 02:55:44 24 4
gpt4 key购买 nike

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');
});




     有人可以告诉我这个错误。我是新手吗?

最佳答案

有一个错字,应该是:process.env.PORT,而不是process.evn.PORT

关于node.js - TypeError:无法读取未定义的属性“PORT”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48578604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com