javascript - TypeError: uri.indexOf is not a function -


so i'm new javascript , i'm attempting build web application in node.js. i'm want add user authentication app passport.js. when try start server on command prompt, keep receiving error:

typeerror: uri.indexof not function @ checkreplicasetinuri (c:\spectray\node_modules\mongoose\lib\index.js:115:30) @ mongoose.connect (c:\spectray\node_modules\mongoose\lib\index.js:238:40) @ object.<anonymous> (c:\spectray\server.js:15:10) @ module._compile (module.js:570:32) @ object.module._extensions..js (module.js:579:10) @ module.load (module.js:487:32) @ trymoduleload (module.js:446:12) @ function.module._load (module.js:438:3) @ module.runmain (module.js:604:10) @ run (bootstrap_node.js:394:7) @ startup (bootstrap_node.js:149:9) @ bootstrap_node.js:509:3 

here's server.js file:

var express = require('express'); var app = express(); var port = process.env.port || 8080; var mongoose = require('mongoose'); var passport = require('passport'); var morgan = require('morgan'); var cookieparser = require('cookie-parser'); var bodyparser = require('body-parser'); var session = require('express-session'); var flash = require('connect-flash'); var db = require('./config/database.js');  var configdb = require('./config/database.js');  mongoose.connect(db);  app.use(morgan('dev')); app.use(cookieparser()); app.use(bodyparser.urlencoded({ extended: true })); app.use(bodyparser.json());  app.set('view engine', 'ejs');  app.use(session({ secret: 'penniesfromheaven', resave: true, saveuninitialized: true })); app.use(passport.initialize()); app.use(passport.session()); app.use(flash());  require('./app/routes.js')(app, passport);  app.listen(port); console.log('the magic happens on port ' + port); 

what dong wrong?

you can add url value database.js

//database.js module.exports = {    url: "mongodb://localhost:27017/sampledb" } 

this should in app.js

var db = require('../config/database.js');  mongoose.connect(db.url) 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -