运行Node.js服务器时出现问题

Issue on running Node.js server

本文关键字:问题 服务器 Node js 运行      更新时间:2023-09-26

当我在Node.js上运行服务器im时,我得到了以下错误我不知道"无法读取未定义的属性'length'"和以下问题。

MySQL Failure.
{ [Error: connect ETIMEDOUT 211.189.127.226:3306]
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
address: '211.189.127.226',
port: 3306,
fatal: true }
TypeError: /home/ubuntu/workspace/Node.JS Server/Streaming/views/page/index.ejs:62
60|                     <div id="tabs-1">
61|                         <table class="broadcast_list_table">
>> 62| <%
63|                             for(var i=0; i<=(room.length/5); i++) {
64| %>
65|                                 <tr>
 Cannot read property 'length' of undefined
at eval (eval at <anonymous> (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/ejs/lib/ejs.js:236:14), <anonymous>:48:50)
at eval (eval at <anonymous> (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/ejs/lib/ejs.js:236:14), <anonymous>:87:73)
at exports.compile (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/ejs/lib/ejs.js:249:15)
at Object.exports.render (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/ejs/lib/ejs.js:287:13)
at View.exports.renderFile [as engine] (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/ejs/lib/ejs.js:317:20)
at View.render (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/express/lib/view.js:76:8)
at Function.app.render (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/express/lib/application.js:505:10)
at ServerResponse.res.render (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/express/lib/response.js:756:7)
at Query._callback (/home/ubuntu/workspace/Node.JS Server/Streaming/routes/index.js:42:17)
at Query.Sequence.end (/home/ubuntu/workspace/Node.JS Server/Streaming/node_modules/mysql/lib/protocol/sequences/Sequence.js:66:24)
GET / 500 127413ms
GET / 500 125181ms`

错误的可能性如下。

  • 房间对象未定义,因此它变为undefined.length。若要解决此问题,请确保在定义该对象的任何位置都不应定义房间对象
  • 尝试使用Object.keys(room).length。这将返回对象的长度