CNode

nodeclub后台添加标签的时候报错退出

Ssususu发布于13 年前最后回复13 年前4 回复4860 浏览0 收藏

爆如下错误,这个是什么问题? node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: Cannot read property 'length' of null at Promise. (/data/home/htdocs/nodeclub/controllers/tag.js:125:13) at Promise. (/data/home/htdocs/nodeclub/node_modules/mongoose/lib/promise.js:120:8) at Promise. (events.js:67:17) at Promise.emit (/data/home/htdocs/nodeclub/node_modules/mongoose/lib/promise.js:59:38) at Promise.complete (/data/home/htdocs/nodeclub/node_modules/mongoose/lib/promise.js:70:20) at /data/home/htdocs/nodeclub/node_modules/mongoose/lib/query.js:876:30 at Array.0 (/data/home/htdocs/nodeclub/node_modules/mongoose/lib/utils.js:394:16) at EventEmitter._tickCallback (node.js:192:40)

谢谢~

查看回复

回复 (4)

C
cncduLee#1·13 年前

我也出这个错了!!!!!enter image description here

enter image description here

C
cncduLee#2·13 年前

enter image description here

C
cncduLee#3·13 年前

好吧,我找到解决办法了:

tag.js 125行:判断改成:

if (tags!==null && tags.length > 0) {
  res.render('notify/notify', {error: '这个标签已存在。'});
  return;
}

因为首次添加标签的时候,数据库还不存在tags这张表,所以你去查,就会报错。 所以而且判断数组长度的时候,数组要存在。。。

^o^

E
ericlc#4·13 年前

nodeclub后台 在哪添加标签啊?还没找到,在线等

参与回复
登录后即可参与回复。登录