繁体   English   中英

关于运行Node.js服务器的问题

[英]Issue on running Node.js server

当我运行Node.js的新服务器时,出现以下错误,我不知道“无法读取未定义的属性'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。 这将返回对象的长度

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM