使用node+mongodb搭建简单个人博客——第一章遇到的问题
问题一:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
解决办法:
将index.js文件,catch模块中的
bson = require('../build/Release/bson');
改为:
bson = require('../browser_build/bson');
如图所示:
问题二:
express-session deprecated undefined resave option; provide resave option app.js:39:9
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option app.js:39:9
解决办法:
添加 resave: false,
saveUninitialized: true,
app.use(session({ secret: settings.cookieSecret, key: settings.db, //cookie name cookie: {maxAge: 1000 * 60 * 60 * 24 * 30}, //30days resave: false, saveUninitialized: true, store: new MongoStore({ db: settings.db, host: settings.host, port: settings.port }) }));