Trouble with (installing?) MongoDB

So I’ve jumped into learnyoumongo, and I seem to be having an issue with the Find challenge, or my install isn’t right. It got to the point where I basically had the solution bracket for bracket and it still won’t register. After having dug around for people having the same problem, I think there is something wrong with my install.

I’m on my third c9 workspace fir learnyoumongo, making sure to take each step with meticulous accuracy. Everything still seems perfect but I’m getting the same error:

~/workspace $ learnyoumongo verify solution.js
db.collection(‘parrots’).remove({}, function(err) {

TypeError: Cannot read property ‘collection’ of undefined
at Exercise. (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/exercises/find/exercise.js:37:5)
at next (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:260:17)
at Exercise.end (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:266:5)
at Workshopper.end (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper/workshopper.js:191:12)
at Workshopper.done (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper/workshopper.js:323:19)
at Exercise. (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:149:14)
at /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:136:16
at Exercise. (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/filecheck.js:10:14)
at FSReqWrap.oncomplete (fs.js:82:15)

I’ve seen others with this same error, but gotten by people who were able to resolve it in ways that I have already checked. So again, I believe this is an installation issue. I got errors but am not sure what they mean or if they are critical (I will post as first comment). Some insight on this issue would be very much appreciated.

Here is what happens in my terminal during install:

:~/workspace $ npm install learnyoumongo -g
npm WARN peerDependencies The peer dependency kerberos@~0.0 included from mongodb-core will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.

kerberos@0.0.21 install /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/mongodb/node_modules/kerberos
(node-gyp rebuild) || (exit 0)

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
make: Entering directory /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/mongodb/node_modules/kerberos/build' CXX(target) Release/ CXX(target) Release/ CC(target) Release/ ../lib/kerberosgss.c:36:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas] #pragma clang diagnostic push ^ ../lib/kerberosgss.c:37:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas] #pragma clang diagnostic ignored "-Wdeprecated-declarations" ^ ../lib/kerberosgss.c: In function ‘authenticate_gss_client_wrap’: ../lib/kerberosgss.c:446:19: warning: variable ‘server_conf_flags’ set but not used [-Wunused-but-set-variable] char buf[4096], server_conf_flags; ^ ../lib/kerberosgss.c: At top level: ../lib/kerberosgss.c:1236:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas] #pragma clang diagnostic pop ^ CC(target) Release/ CXX(target) Release/ SOLINK_MODULE(target) Release/ /usr/bin/ld: cannot find -lkrb5 /usr/bin/ld: cannot find -lgssapi_krb5 collect2: error: ld returned 1 exit status make: *** [Release/] Error 1 make: Leaving directory/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/mongodb/node_modules/kerberos/build’
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.2.0-c9
gyp ERR! command “/home/ubuntu/.nvm/versions/node/v4.4.5/bin/node” “/home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” "rebuild"
gyp ERR! cwd /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/node_modules/mongodb/node_modules/kerberos
gyp ERR! node -v v4.4.5
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
/home/ubuntu/.nvm/versions/node/v4.4.5/bin/learnyoumongo -> /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo/learnyoumongo.js
learnyoumongo@3.0.2 /home/ubuntu/.nvm/versions/node/v4.4.5/lib/node_modules/learnyoumongo
├── chalk@1.0.0 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
├── through2@0.6.5 (xtend@4.0.1, readable-stream@1.0.34)
├── workshopper-exercise@2.3.0 (after@0.8.1, visualwidth@0.0.1, chalk@0.4.0, tuple-stream@0.0.2, split@0.3.3, xtend@2.1.2, through2@0.4.2, i18n-core@1.3.3)
├── workshopper@2.5.0 (map-async@0.1.1, xtend@3.0.0, visualwidth@0.0.1, chalk@0.4.0, mkdirp@0.3.5, colors-tmpl@0.1.1, i18n-core@1.3.3, optimist@0.6.1, terminal-menu@2.1.1, msee@0.1.2)
└── mongodb@2.0.55 (readable-stream@1.0.31, es6-promise@2.1.1, kerberos@0.0.21, mongodb-core@1.2.31)

Also, I have been running
"learnyoumongo verify solution.js"
If I run it with the actual filename instead of “solution” I get a different error:

~/workspace $ learnyoumongo verify finderspeepers.js
throw err;

Error: Cannot find module 'mongodb’
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/home/ubuntu/workspace/finderspeepers.js:2:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)

Your submission results compared to the expected:

             ACTUAL                                 EXPECTED                


“” != “[ { _id: 5776b57e5d41212a0b277b20, name: ‘Jenny’, age: 10 } ]”
!= “”


✗ Submission results did not match expected!


Your solution to FIND didn’t pass. Try again!

You could try a free hosted mongo solution like

If share the instructions you have I can try to replicate it.

Here is the exercise:

Learn MongoDB
Exercise 3 of 9

Here we will learn how to search for documents.

In this exercise the database name is learnyoumongo.
So, the url would be something like: mongodb://localhost:27017/learnyoumongo

Use the parrots collection to find all documents where age
is greater than the first argument passed to your script.

Using console.log, print the documents to stdout.


To connect to the database, one can use something like this:

var mongo = require('mongodb').MongoClient
mongo.connect(url, function(err, db) {
  // db gives access to the database

To get a collection, one can use db.collection(’’).

To find a document or documents, one needs to call find() on the collection.

Find is a little bit different than what we are used to seeing.

To access the arguments you can use the process.argv array of strings (the first argument is stored at the third position process.argv[2]). To convert to an integer, you could use parseInt()

Here is an example:

  name: 'foo'
}).toArray(function(err, documents) {


If your program does not finish executing, you may have forgotten to
close the db. That can be done by calling db.close() after you
have finished.


» To print these instructions again, run: learnyoumongo print
» To run your program, run: learnyoumongo run [solution.js]
» To verify your program, run: learnyoumongo verify [solution.js]
» For help run: learnyoumongo help

and here is my code:

// Find
var mongo = require(‘mongodb’).MongoClient;
var age = parseInt(process.argv[2], 10);
var url = ‘mongodb://localhost:27017/learnyoumongo’;
mongo.connect(url, function(err, db){
if (err) throw err;

    age: {
        $gt: +age
}).toArray(function (err, documents){
    if (err) throw err;


Alright I got the code you provided in the last post to pass.
I setup node using these directions not the directions that learnyoumongo gives.

Tried it, but alas no difference. The trouble seems to be with the installation of learnyoumongo rather than mongodb

FIXED - found this from evan lucas
It looks like when you run the exercise it clears the files? Anyway, he suggested running:
$ npm install mongodb
every time you hit this error to restore the files. Worked like a charm.On to next challenge.

I literally just did this.

sudo apt-get install -y mongodb-org
mkdir data
echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"' > mongod
chmod a+x mongod

npm install -g learnyoumongo

and start the server with

1 Like