Uncaught exception: ReferenceError: console is not defined

While writing codes in javascript on Mongoshell , I am getting the above error. Please look into it.

Please include a screenshot showing what you type and what the error is (the output).

Are you using mongo or mongosh? If the former, then there is no console object. I’d recommend switching to mongosh, which is the new MongoDB Shell that we will GA very soon. If you are already using mongosh, please post a screenshot or a copy-paste of your script.

It seems print could serve the same purpose on mongo, but I’m testing here https://mws.mongodb.com/?version=4.4, and am not very sure what the binary is…

Thanks for your reply. You advise me to start mongosh. I have installed MongoDB Server 4.4. To start mongosh , should I have to configure it manually ?
To start manually means - I have to write codes in YAML format in a text editor like notepad and access it from MongoDB Sever in command prompt. Please clarify.

You can download mongosh for your operating system here: https://www.mongodb.com/try/download/shell. It does not come bundled with the server.

Ok, I shall install mongos for my Windows10 operating system with the link you provided to me. But let me point out to you regarding your reply that mongos does not come bundled with the server (MongoDB Server 4.4). But , my screen shot is showing something different. But, still I am not able to open it.

mongos and mongosh are different apps
mongosh is the new shell interface Massimiliano_Marcon is asking you to install

mongos is used to start mongos server process (for replication/sharding)
From your screenshot what process/app you started and what error you are getting?

Sorry for reply in late. I get your point. Mongos and mongosh are different applications. I installed mongosh. This is functional in javascript code and console object is compatible here. Thank you for giving me the solution.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.