当我运行节点应用程序时,我得到了这个
/home/folder/app_name/node_modules/mongodb/lib/mongo_client.js:785
throw err;
^
ReferenceError: debug is not defined
at /home/folder/app/node_modules/sessionstore/lib/databases/mongodb.js:95:11
at args.push (/home/folder/app/node_modules/mongodb/lib/utils.js:403:25)
at /home/folder/app/node_modules/mongodb/lib/mongo_client.js:254:21
at connectCallback (/home/folder/app/node_modules/mongodb/lib/mongo_client.js:933:5)
at /home/folder/app/node_modules/mongodb/lib/mongo_client.js:782:11
at process._tickCallback (internal/process/next_tick.js:150:11)
这是我的代码nodejs
mongoose.connect('mongodb://XXX:27017/project')
知道这条消息的含义以及如何修复它?
答案 0 :(得分:1)
我找到了解决方案。 实际上,由于我的mongodb服务器安装在另一台服务器(不同于nodejs)中,我只需要在createsessionstore中添加主机和端口
而不是:
sessionStore = require('sessionstore').createSessionStore({type:'mongodb'}),
使用此
sessionStore = require('sessionstore').createSessionStore({
type:'mongodb',
host: 'xx.xx.xx', // optional
port: 27017, // optional
dbName: 'projectname', // optional
//collectionName: 'sessions',// optional
//timeout: 10000 // optional
// authSource: 'authedicationDatabase', // optional
// username: 'technicalDbUser', // optional
// password: 'secret' // optional
// url: 'mongodb://user:pass@host:port/db?opts // optional
}),