TypeError: Cannot read property 'length' of undefined! 版本问题吧?
发布于 1个月前 作者 huaziHear 188 次浏览 来自 问答

初学node,到处撞墙!今天google了一天,也没有解决! "dependencies": { "body-parser": "~1.12.4", "bootstrap": "^3.3.4", "cookie-parser": "~1.3.5", "debug": "~2.2.0", "ejs": "~2.3.1", "express": "~4.12.4", "morgan": "~1.5.3", "serve-favicon": "~2.2.1", "mongodb": "1.4.15", "express-session": "1.9.1", "connect-mongo": "0.8.0", "connect-flash": “0.1.1” }

var session = require(‘express-session’); var MongoStore = require(‘connect-mongo’)(session);

大概定位到这!已经接近奔溃了

2 回复

好吧!我再描述一下问题。错误提示:TypeError: Cannot read property ‘length’ of undefined at processResults (/workdir/project/blog/node_modules/mongodb/lib/mongodb/db.js:1603:31) at /workdir/project/blog/node_modules/mongodb/lib/mongodb/db.js:1641:20 at /workdir/project/blog/node_modules/mongodb/lib/mongodb/db.js:1179:7 at /workdir/project/blog/node_modules/mongodb/lib/mongodb/db.js:1912:9 at Server.Base._callHandler (/workdir/project/blog/node_modules/mongodb/lib/mongodb/connection/base.js:448:41) at /workdir/project/blog/node_modules/mongodb/lib/mongodb/connection/server.js:481:18 at MongoReply.parseBody (/workdir/project/blog/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5) at null.<anonymous> (/workdir/project/blog/node_modules/mongodb/lib/mongodb/connection/server.js:439:20) at emit (events.js:107:17) at null.<anonymous> (/workdir/project/blog/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)

初步判断是由于express-session和connect-mongo的版本问题导致! "express-session": "1.9.1", "connect-mongo": "0.8.0” 但是修改了一下版本发现问题仍然存在,不知道哪个版本是没有这个bug的

回到顶部