Load validateLab1.js

Hi,

I have a pipeline with 23 documents, but when I load the validateLab1.js file with the following command:
load(‘C:/my/path/chapter1/validateLab1.js’)

I have the following error returned:

2018-10-18T15:12:55.484+0200 E QUERY [thread1] SyntaxError: missing ; before
statement :
@(shell):1:1
2018-10-18T15:12:55.489+0200 E QUERY [thread1] Error: error loading js file:
C:/my/path/chapter1/validateLab1.js :
@(shell):1:1

I don’t modified the js file, I have just unzip it.
How can I load this file ?

Thanks
Melanie

Hi,

Please try escaping the slashes: "c:\\my\\path\\". Anyway, if you go to c:\my\path\chapter1 and start the mongo shell from that location you could load the file using load('validateLab1.js').

Hope this helps.

José Carlos

With "c:\\my\\path\\" the error is that the file doesn’t exist.
With the MongoShell on the same folder as “chapter1” I have the same error described in my first post.

I try to copy/paste the content of validateLab1.js on the shell but there is always the same issue :

2018-10-18T15:58:06.007+0200 E QUERY [thread1] SyntaxError: missing ; before
statement @(shell):2:6

I try to load the JS file on my own Mongo server, it works.

I needed help of my IT support to open connection to Atlas cluster server (some proxy issues).
Can this error happens if I have some rights issues?

Is it possible to make the course with a local Mongo?

Melanie

Hi,

My IT Support open all connections on firewall but I have always the same error:

2018-10-22T09:56:52.203+0200 E QUERY [thread1] SyntaxError: missing ; before statement :
@(shell):1:1

2018-10-22T09:56:52.204+0200 E QUERY [thread1] Error: error loading js file:
C:/my/path/chapter1/validateLab1.js :

When I try to load the JS file on my own Mongo server, it works.

Is it possible to make the course with a local Mongo?
The deadline to complete labs is coming soon. How validate my answers?

Thanks.

Melanie

Hi,

You could use your local server, but you would need to import the database. Anyway, please make sure you are connecting to the Atlas cluster from the directory where you downloaded the validateLab1.js file, and load the file without the path: load('validateLab1.js'). Also make sure your Mongo Shell version is 3.6 or above.

José Carlos

Same issue if I load the file without the path:

2018-10-22T13:40:39.355+0200 E QUERY [thread1] SyntaxError: missing ; before
statement :
@(shell):1:1

2018-10-22T13:40:39.357+0200 E QUERY [thread1] Error: error loading js file:
validateLab1.js :
@(shell):1:1

The command db.version() give me 3.6.8 as I use the Mongo Atlas Shell.

I will try to import the database from Atlas.

I do a mongodump with:
"C:/Program Files/MongoDB/Server/3.4/bin/mongodump" --host cluster0-shard-00-00-jxeqq.mongodb.net --port 27017 --authenticationDatabase admin --ssl -u m121 -p aggregations -d aggregations

I can load the js file in local without issue and give the right answer.
So I am not blocked anymore to do the stage but I don’t know why I have issues on Atlas server.

Thanks a lot for helping me.

Glad you managed to run it locally! Anyway, it sounds strange it failed on Atlas, because the shell version is the same in both cases, as you connect to Atlas from your local shell. Please note that 3.6.8 is the MongoDB server version on Atlas, not your local shell version.

José Carlos