使用node.js 的express框架配置将session存储到mongodb时出错:
TypeError: Cannot read property 'Store' of undefined
express版本:3.3.4
connect-mongo:0.3.3
一开始按照网上的一些资料加载connect-mongo模块的写法为:
//加载模块
var MongoStore= require("connect-mongo");
//配置express session
app.use(express.session({
secret:setting.cookieSecret,
db: seeting.db
}));
启动程序报错:TypeError: Cannot read property 'Store' of undefined
经过排查和资料,查看connect-mongo的Readme.md,其中有段描述为:
With express:
var express = require('express');
var MongoStore = require('connect-mongo')(express);
app.use(express.session({
secret: settings.cookie_secret,
store: new MongoStore({
db: settings.db
})
}));
With connect:
var connect = require('connect');
var MongoStore = require('connect-mongo')(connect);
将var MongoStore= require("connect-mongo");修改为:
var MongoStore = require('connect-mongo')(express);
重启启动OK,问题解决!
相关推荐
title: 'Vue.js路由报错:TypeError: Cannot read property ''_c'' of undefined'错误详情:像上面这
Vue打包Cannot read property 'tapPromise' of undefined报错处理.docx
资源分类:Python库 所属语言:Python 资源全名:photon-1.1.6.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' 点开错误的文件,标注错误的地方是这样的一段代码: import {normalTime} from './timeFormat'; module....
1、标称阻值为了满足使用者的要求,生产厂生产了各种阻值的电阻器。即使如此,也无法做到使用者想要什么样阻值的电阻器就会有什么样电阻器的成品。为了便于生产和使用,国家统一规定了一系列阻值作为电阻器阻值的...
翻译过来是类型为“type”的TypeError对象没有len(),我报错的代码是: #coding=utf-8 print(请输入一个字符串:) a = input('') #回文的长度至少为2 if len(str) < 2: print('请不要输入空字符串!') a = ...
主要介绍了Vue 报错TypeError: this.$set is not a function 的解决方法,分享给大家,需要的朋友们下面随着小编来一起学习学习吧
主要给大家介绍了关于Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' 的解决方法,文中介绍的非常详细,需要的朋友们下面来一起看看吧。
同一相站点,有些页面的客户端验证能工作,而有些死活不行。打开页面就出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null错误
TypeError: Cannot read property ‘name’ of undefined at z (http://127.0.0.1:38175/appservice/__dev__/WAService.js:2:1560728) at Ie ...
redux-devtools.crx 版本 2.15.3 大小 5.6 MB 解决 使用安装redux.devTools后 Cannot read property 'state' of undefined 问题
TypeError: cannot concatenate ‘str’ and ‘int’ objects print str + int 的时候就会这样了 python + 作为连接符的时候,不会自动给你把int转换成str 补充知识:TypeError: cannot concatenate ‘str’ and ...
endnote文献管理软件中的,文献导入时,可以使用它来导入维普和万方的文献目录了,
TypeError:Uncaught TypeError: Cannot read property 'XXX' of undefined 调用了对象不存在的方法。 (2) TypeError:'undefined'is not an object 多半是使用了某个变量,拿到了一个尚未分配的变量,即undefind...
为大家分享了一个解决jquery插件:TypeError:$.browser is undefined报错的方法,解决报错问题的方法也很简单,需要解决此类问题的朋友不要错过这篇文章。
中文版的tomcat5.5 由jaxmao汉化
在调整loss计算的时候遇到了TypeError: only integer tensors of a single element can be converted to an index这个问题,原来的计算公式为: self.loss_D = (self.loss_D_fake + self.loss_D_real) * 0.5 调整后...
SpringBoot整合Activiti简单示例,示例中包含正常流程执行、中文乱码解决、指定流程节点执行人等测试代码。
本文研究的主要是Python使用pickle模块存储数据报错解决方法,以代码的形式展示,具体如下。 首先来了解下pickle模块 pickle提供了一个简单的持久化功能。...TypeError: write() argument must be str, not byte