Error in loading file

command:
load(‘validateLab1.js’)

error:
2020-02-19T15:37:51.665+0545 E QUERY [thread1] SyntaxError: missing ; before statement :
@(shell):1:1

2020-02-19T15:37:51.665+0545 E QUERY [thread1] Error: error loading js file: validateLab1.js :
@(shell):1:1

Hi @sambo2299,

Please make sure that you have downloaded validateLab1.js file in the handouts for the lab. Also you need to connect to the mongo shell from the same directory where you have saved the validateLab1.js file using the terminal. The file should be reachable from the prompt.

Please let me know, if you have any questions.

Thanks,
Sonali

1 Like

hi @Sonali_Mamgain
i have file and the mongo shell connected from same directory
and the file i downloaded was from handouts zip file called chapter1.zip

for checking i created pipeline variable in test.js file in same directory and loaded the pipeline from that file by the command:
load(‘test.js’)
which was loaded fine resulting the output " true " and i was able to use the pipeline for aggregation

but for the validateLab1.js and validateLab2.js i was not able to load them and it resulted giving error

error:
2020-02-19T15:37:51.665+0545 E QUERY [thread1] SyntaxError: missing ; before statement :
@(shell):1:1

Hi @sambo2299,

Please share the directory structure and from which directory you have run the mongo connection string.

Also share the screenshot of the load('validateLab1.js') command and the error message.

Thanks,
Sonali

hi @Sonali_Mamgain

this is the path of the dir from where i ran mongo shell
/home/samyog/learn/mongoUniversity/m121/chapter1
image

and the screen shot with error

regards

Hi @sambo2299,

Thanks for sharing the screenshots!!

I believe you will need to upgrade the MongoDB in your local system. You can check the installed version using:

mongo --version

Please upgrade to the latest version.

I hope it helps. Please let me know if you still get the same error.

Thanks,
Sonali

hi @Sonali_Mamgain
isn’t mongoshell is connected to the mongod server from mongodb.net
and i am able to load other js file like the one i created,
and i have multiple mongo version in my development system i dont have single version installed,
i basically start my mongod server as need for project basis

Out of curiosity could you please share the first 5 lines of each file. Please enclose the output within the html pre tag.

Hi @sambo2299,

Updating the mongo shell worked for some users as they were using older versions of MongoDB installed in their systems.

There is a possibility that validateLab1.js file got modified. Please share the complete screenshot of the file.

It should be similar to the screenshot attached below:

If your file looks different make sure that you download the handout again and then retry loading the file in the mongo shell.

Thanks,
Sonali

hi,
here is the screen shot of the file

nevertheless using newer version of mongo executable file from newer mongodb i was able to load file
thanks for the help @Sonali_Mamgain
regards,
samyog

1 Like