[ Node.js ]学习过程中遇到的问题, TypeError:Cannot read property 'Store' of undefined
TypeError: Cannot read property ‘Store’ of undefined 解决方案明细 是由于版本问题引起
// package.json 修改版本
"connect": "1.8.5",
"connect-mongo": "0.1.9",
"express": "2.5.8",
//app.js 中改变获取方法
var express = require('express');
var MongoStore = require('connect-mongo')(express),
TypeError: object is not a functionat Object.<anonymous> 如果报如上错误就是express 版本问题, "express": “2.5.8” 版本的写法:
var app = module.exports = express.createServer();
app.listen(3000);
而新版本 express@3.0.0rc3 是这用写法:
//app.set('port', process.env.PORT || 3000);
var app = express();
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});