Chapter 1 - Lab 1 : Can not able to execute validateLab1 method


I tried to execute validateLab1 from the location where I created file by connecting to Atlas. But got below error

MongoDB Enterprise Cluster0-shard-0:PRIMARY> load("\validateLab1.js")
MongoDB Enterprise Cluster0-shard-0:PRIMARY> validateLab1(pipeline)
2019-01-09T21:17:47.897+0530 E QUERY [thread1] ReferenceError: validateLab1 is not defined :

Could anyone please help me with this error?


The validation scripts are NOT run inside the Mongo shell. You run them on the Linux command line.

Could you please help me with the steps.

This is the first time I’m doing the course in MongoDb University.

There are no steps :slight_smile:

You just have to run the same command, but NOT inside the Mongo shell. The Linux shell is the one you connect to when you run vagrant connect.

Really did not understood.

Tried to execute command in linux also but no luck.

If you provide some screen shot or command it will be great. Otherwise I have to Un-register from course. Without doing lab it will be of no use :frowning:

Then could you please provide screenshots or a copy/paste of the full input to show what is going wrong? You’re not offering much information.

Below is the terminal screen shot

if above procedure is not executed in Cluster Mongo shell, How linux will also identify load method and make a connection to cluster DB and execute the command

I am very, very sorry. I am wrong.

I had misread which forum we’re in! I thought this was M001, instead of M121. In the case of M121 the validation will most likely happen inside the Mongo shell. My sincere apologies for this mistake.

@ Sujay

I think that you may have a problem with the load of the JavaScript file. Please try simply entering the command


at the shell command prompt. You should see the code that matches the ‘validateLab1.js’ file on your system.

If you still have a problem, post back here and I’ll try this on my Windows system to see if I can reproduce your error. Good luck.

Thanks DHz

I figured out what was the problem and fixed it to work.

Hi Sujay,

Could you please suggest what was the exact issue here. I am facing same issue while trying to validate the .js file.

I get the correct answer but not was possible to load validateLab1.js.

Any help

Can you exit the shell and perform ls? (or dir if running windows)

1 Like

Hello Steeve

With your suggestion, I found the solution. For future reference proceed like this:

  • Create a folder m121.
  • Save folder in folder m121.
  • Unzip the file.
  • Open Terminal in m121.Chapter1 folder
  • From this location, start the mongo shell.
  • Follow the rest of instruction found in: Chapter 1: Basic Aggregation - $match and $project

Thank you, Steeve Juneau and best regards


Simple solution depicted by Javier_Mauricio_91175 that I followed:

  • Create a folder m121.
  • Download and save found in the Handouts (right of the lab page) into folder m121.
  • Unzip the file.
  • Open Terminal in m121.Chapter1 folder.
  • From this location, start the mongo shell.
  • Follow the instructions in the Lab page.

Thank you Javier :clap:

1 Like

What is the command line to start the mongo shell? i’m using mongo but the connection fails .
I’m a beginner in mongoshell environment


@ Alessandro_65603

First of all, this doesn’t appear to be about the validateLab1 script. If it’s not, I would very strongly recommend that you create a new post about your specific problem.

Second, the command to start the shell is ‘mongo’ run from the command line. If you’re getting a connection failure (which appears to be your issue) then show in your new post what the error message is and we’ll try to help. Good luck.

1 Like