SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error trying to connect to a Mongo DB

    Hello, I'm taking the Jumpstart Node.js course while trying to connect to MongoDB I receive the following error:
    Code:
    Microsoft Windows [Version 6.2.8250]
    (c) 2012 Microsoft Corporation. All rights reserved.
    
    C:\Users\Paul>cd../../authentication
    
    C:\authentication>node app
    
    C:\authentication\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:2
    41
        if(databaseName.indexOf(invalidChars[i]) != -1) throw new Error("database
                                                              ^
    Error: database names cannot contain the character '.'
        at validateDatabaseName (C:\authentication\node_modules\mongoose\node_module
    s\mongodb\lib\mongodb\db.js:241:59)
        at new Db (C:\authentication\node_modules\mongoose\node_modules\mongodb\lib\
    mongodb\db.js:79:3)
        at NativeConnection.doOpen (C:\authentication\node_modules\mongoose\lib\driv
    ers\node-mongodb-native\connection.js:42:15)
        at NativeConnection.Connection._open (C:\authentication\node_modules\mongoos
    e\lib\connection.js:375:15)
        at NativeConnection.Connection.open (C:\authentication\node_modules\mongoose
    \lib\connection.js:234:8)
        at Mongoose.connect (C:\authentication\node_modules\mongoose\lib\index.js:15
    0:15)
        at connect (C:\authentication\lib\db.js:16:12)
        at Object.<anonymous> (C:\authentication\lib\db.js:11:1)
        at Module._compile (module.js:449:26)
        at Object.Module._extensions..js (module.js:467:10)
    
    C:\authentication>
    The offending script seems to be lib/db.js. I'm new to node.js so any help would be appreciated. Thanks.

    --Ogian
    Attached Files Attached Files
    Last edited by molona; Nov 5, 2012 at 08:55. Reason: adding code tags

  2. #2
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,025
    Mentioned
    211 Post(s)
    Tagged
    1 Thread(s)
    Off Topic:

    Can't help you just yet because I'm still waiting for my copy of the book and I'm not really familiar with it but I'm sure that some other sitepointer will be able to assist you. I hope that you didn't mind that I added code tags to your post. I think it makes the post easier to read

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    41
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I've never used Node.js, so this is just a guess, but is it possible that the problem occurs because there is a space at the beginning of the address-variable?

  4. #4
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks. Not a problem.

  5. #5
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Denk, removing the space is the answer. Thank you. I checked to source code for the book and that has the same typo. Thanks again.

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    41
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Nice! Glad I could help

    Might be an idea to e-mail the author of the book and report the typo.

  7. #7
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will. Thanks.

  8. #8
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,025
    Mentioned
    211 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Ogian View Post
    @Denk ;, removing the space is the answer. Thank you. I checked to source code for the book and that has the same typo. Thanks again.
    Now I feel ashamed of myself because I didn't even take the time to look at your code, believing that if I couldn't see it in context of the book I would not be able to help...

    Glad that it is sorte out and you found an errata

  9. #9
    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 Ogian View Post
    @Denk, removing the space is the answer. Thank you. I checked to source code for the book and that has the same typo. Thanks again.
    I'm currently going through the book and didn't even pick up on this one - adding it to my list of errata

    Maybe it's because I type out all the code samples rather than copying pasting, or maybe my brain just automatically ignored the space. (Or also very likely, didn't really notice it.)
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  10. #10
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @everyone Thanks for your quick responses.


Tags for this Thread

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
  •