[SOLVED] Learnyoumongo exercise 3: cannot read property 'collection' of undefined

[SOLVED] Learnyoumongo exercise 3: cannot read property 'collection' of undefined
0

#1

I can’t get any code to run on this exercise due to the error listed in the title. It’s giving me a link to a file in learnyoumongo’s exercise files, so it’s not even from something in my code (which, due to frustration and testing, I’m using their solution in my code). Here’s a photo of the full error:

Anyone else had this problem or can tell me how to fix it? I really wanted to get through this module tonight. I have the database running in a separate terminal window, and it does appear to be running when I attempt to run this file. No clue what to do to fix this so I can progress.


#2

Update/solution: So I ran ‘npm install mongodb’ and then ran the run code, and it worked for some odd reason. Even though I’d already done the install line before exercise 1…maybe it had to be done in the current terminal for some reason? No idea. I guess in case anyone else runs into this issue…try this. Otherwise this thread can be deleted if need be. (I couldn’t find the way to delete it myself.)