我已经npm install connect-flash 为什么还出现TypeError: Object #<IncomingMessage> has no method 'flash'
发布于 2年前 作者 nodejswang 2211 次浏览
4 回复

我也出现这个问题 Express 500 TypeError: Object #<IncomingMessage> has no method ‘flash’

at E:\node\node\weibo\microblog\routes\index.js:22:5
at callbacks (E:\node\node\weibo\microblog\node_modules\express\lib\router\index.js:164:37)
at param (E:\node\node\weibo\microblog\node_modules\express\lib\router\index.js:138:11)
at pass (E:\node\node\weibo\microblog\node_modules\express\lib\router\index.js:145:5)
at Router._dispatch (E:\node\node\weibo\microblog\node_modules\express\lib\router\index.js:173:5)
at Object.router (E:\node\node\weibo\microblog\node_modules\express\lib\router\index.js:33:10)
at next (E:\node\node\weibo\microblog\node_modules\express\node_modules\connect\lib\proto.js:190:15)
at Object.cookieParser [as handle] (E:\node\node\weibo\microblog\node_modules\express\node_modules\connect\lib\middleware\cookieParser.js:60:5)
at next (E:\node\node\weibo\microblog\node_modules\express\node_modules\connect\lib\proto.js:190:15)
at Object.methodOverride [as handle] (E:\node\node\weibo\microblog\node_modules\express\node_modules\connect\lib\middleware\methodOverride.js:49:5)

官方怎么没人出来解决这个问题呢?

首先你要问问自己为什么要安装connect-flash express3中已经有了connect-flash 不用安装。可以直接使用。

我好像安装了,我得到的信息跟楼上相反,是express3中不包含flash,所以要手动。

在app.js中,加入app.use(flash());

回到顶部