问题描述
- nodejs在控制台上报了如下错误,求解???
- $ node app
F:movieapp.js:49
store: new mongoStore({
^^^^^
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3这是报错部分的代码: app.use(session({
secret: 'imovie'
resave: false
saveUninitialized: true
store: new mongoStore({
url: dbUrl
collection: 'sessions'
})
}))
解决方案
语法错误,意外的标识符;
是不是缺少mongoStore的引用?
解决方案二:
是不是不支持参数:url
var MongoStore = require(‘connect-mongo’)(session); store: new MongoStore({db: settings.dbhost: settings.hostport: settings.port})
解决方案三:
var MongoClient = require(‘mongodb’).MongoClient assert = require(‘assert’);var url = '’;//数据库地址// Use connect method to connect to the ServerMongoClient.connect(url function(err db) {assert.equal(null err);console.log(“Connected correctly to server”);db.close();});
时间: 2024-10-29 12:18:32