Learnyoumongo (Mongo in C9) exercise 2 and 3 pitfalls for beginners

Learnyoumongo (Mongo in C9) exercise 2 and 3 pitfalls for beginners
0

#1

Sorry, no explicit solution here - I am writing for those who just need to get off the ground and are trying to understand exactly what is required of them for this tutorial (explicit solution with explanations may come later on my John Codes Stuff blog on Blogspot. Maybe.)

It is important to realize that exercises one and two are not just their own exercises but the necessary steps leading up to getting everything running properly before you can even run your solution for exercise 3.

It took me a while to realize this (duh), so let me repeat the above information: Exercises one and two of the learnyoumongo tutorial get you connected and get the server running in the background. So you can’t do exercise one day, two the next, then come back in a couple days, write your solution for three and expect it to run. After you have put together your solution for exercise three, you have to go back and repeat exercises one and two as the first steps of exercise three.

Before you do exercise 3:

  1. Start a new terminal and enter the command $ learnyoumongo

  2. Select exercise 1 and hit enter

  3. If you have already done exercise one before, this time just enter $ learnyoumongo verify and hit enter

  4. Enter the command $ learnyoumongo

  5. Select exercise 2 and hit enter

  6. When the directions say “To start mongo on port 27017, run mongod --port 27017 --dbpath=./data” don’t do that. Do this:

    $ mongod --port 27017 --dbpath=./data --smallfiles

Otherwise you might get an error that you need to free up space

  1. Open a second terminal and DO EVERYTHING ELSE IN THE SECOND TERMINAL, from “$ npm install mongodb” to “$ learnyoumongo verify [solution.js]” for exercise 2 to everything for exercise 3. Do it all in the second terminal with the db server running in the first terminal.

Side note:

If you are messing around trying to get stuff to work and get the “journal” or the “lock” error followed by the message that it failed to connect, do this:

$ mongod --dbpaths=./data -- repair

…assuming you called your data file “data”

I still have not figured completely why that works, but it worked for me when I encountered CONNECTION errors.


#2

I got the connection error and then tried applying the command you mentioned above:
mongod --dbpaths=./data – repair

But I get the below error:
Error parsing command line: unknown option dbpaths
try ‘mongod --help’ for more information


#3

Apologies for the late reply. My initial post is pretty old (several months at this point) and the learnyounode folks have most likely updated stuff and applied a new solution. Were you able to work through this problem? If so please share. Thanks!