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

Javascript 运行Node.js服务器时出现问题,javascript,mysql,node.js,Javascript,Mysql,Node.js,我在运行服务器im new to Node.js时遇到以下错误 我不知道“无法读取未定义的属性‘长度’”和以下问题 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: /ho

我在运行服务器im new to Node.js时遇到以下错误 我不知道“无法读取未定义的属性‘长度’”和以下问题

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`
MySQL失败。 {[错误:connect-ETIMEDOUT 211.189.127.226:3306] 代码:“ETIMEDOUT”, errno:“ETIMEDOUT”, 系统调用:“连接”, 地址:“211.189.127.226”, 港口:3306, 致命的:真的} TypeError:/home/ubuntu/workspace/Node.JS Server/Streaming/views/page/index.ejs:62 60| 61|
>>62 |错误的可能性如下

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

异常解释了问题所在。您没有定义变量室。我将变量室定义为一个全局变量,但仍然得到相同的错误,可能重复