SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do i Include the Mongoose Module?

    Hi,
    Im only on 'coming to a server near' you page 14.. i wondered how i included the mongDB files in the project?

    I am on windows 7. writing my files in e-editor and have installed supervisor and everything has been going well.

    but i am not sure where to put the mongo application files i downloaded from mongo.
    i have attached my error.

    Thanks for any help or a point in the right direction would be nice.

    Do i have to just put the bin folder in the root of the app or???
    Attached Images Attached Images

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have re ran the npm install and it has included the Mongoose module.
    when i run the app know i get an error saying
    Database names cannot contain the character '.'
    I have looked at all my code and it looks good and I am making the connection properly as i can see.
    var mongoose = require('mongoose');
    var Schema = mongoose.Schema;

    module.exports.mongoose = mongoose;
    module.exports.Schema = Schema;

    // Connect to cloud DB

    var username = "firstProject"
    var password = "Changed for safety!!";
    var address = 'ds033257.mongolab.com:33257/firstproject';
    connect();

    // Connect to Mongo
    // ================
    function connect(){
    var url = 'mongodb://'+ username + ':' + password + address;
    mongoose.connect(url);
    }
    function disconnect() {mongoose.disconnect()}

    it is complaining about drivers in the mongoose\lib\drivers\node-mongodb-native\connection

    Do i need to put the drivers i downloaded from mongo any where in the project .. This is the bit i don't get , if i D/L some drivers or the download you need for windows? what do i do with them? or are they for if you don't want to built in the cloud and you install on your local machine?

    any help or explanation would be good..

  3. #3
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trikkky View Post
    I have re ran the npm install and it has included the Mongoose module.
    when i run the app know i get an error saying
    Database names cannot contain the character '.'
    If your actual password has spaces or @ symbols in it, try removing them and see if that helps

    Next up, the address has to start with an "@" symbol

    Code:
    var address = '@ds033257.mongolab.com:33257/firstproject';
    Quote Originally Posted by trikkky View Post
    Do i need to put the drivers i downloaded from mongo any where in the project .. This is the bit i don't get , if i D/L some drivers or the download you need for windows? what do i do with them? or are they for if you don't want to built in the cloud and you install on your local machine?
    From what I can tell it would be either your password or the fact that the "@" was missing from the beginning of the address. If you did the NPM install then you'll see that in the node_modules directory the "mongoose" module is installed. It in turn has a node_modules folder with its dependencies (one of them should be MongoDB)
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  4. #4
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi trikkky, you don't have to put downloaded drivers in your project. Are you still having trouble after following AussieJohn's post?

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nodeError3.PNGYes I have installed ubuntu in a virtual box and going to try and do it from there as i have never done any terminal/cmd work in windows but have done lots in terminal and vim. so gonna see if it is windows .
    here is my errors when i run app.js
    i do not see a '.' anywhere and have deleted all inputs and typed them in again.

  6. #6
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    OK let us know if Ubuntu makes any difference. One of the interesting thing is you can do is modify modules directly. In this case you could modify mongodb\lib\mongodb\db.js in a text editor to print out

    databaseName

    e.g. console.log(databaseName);

    on line 210. If there is still a problem and you post the output, it might help shed further light on the problem


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •