Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a console bug. please help Mongo is not defined - problem while loading data from the server

C:UsersRobertDesktopFINISH
ode_modulesmongodblibutils.js:123
    process.nextTick(function() { throw err; });
                                  

ReferenceError: mongo is not defined
    at C:UsersRobertDesktopFINISH
outesinfo.js:38:70
    at C:UsersRobertDesktopFINISH
ode_modulesasynclibasync.js:122:13
    at _each (C:UsersRobertDesktopFINISH
ode_modulesasynclibasync.js:46:13)
    at Object.async.each (C:UsersRobertDesktopFINISH
ode_modulesasynclibasync.js:121:9)
    at C:UsersRobertDesktopFINISH
outesinfo.js:34:31
    at handleCallback (C:UsersRobertDesktopFINISH
ode_modulesmongodblibutils.js:120:56)
    at C:UsersRobertDesktopFINISH
ode_modulesmongodblibcursor.js:861:16
    at handleCallback (C:UsersRobertDesktopFINISH
ode_modulesmongodb-corelibcursor.js:171:5)
    at setCursorDeadAndNotified (C:UsersRobertDesktopFINISH
ode_modulesmongodb-corelibcursor.js:505:3)
    at nextFunction (C:UsersRobertDesktopFINISH
ode_modulesmongodb-corelibcursor.js:660:7)

package.json:

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "async": "^0.9.0",
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "^1.10.2",
    "bson": "^4.2.2",
    "client-sessions": "^0.7.0",
    "express": "^4.11.1",
    "express-handlebars": "^2.0.1",
    "mongodb": "^2.2.33"
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
260 views
Welcome To Ask or Share your Answers For Others

1 Answer

Line 38 of info.js references mongo: mongo.ObjectID..., but mongo does not exist in that file. You need to add const mongo = require('mongodb') to the top of the file along with your require of the async module. And for future reference, you can edit posts on StackOverflow rather than replying with detail as an answer.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...