How to Use MERN Stack ReferenceError: js not defined

Hello all,

I am trying to get back into the swing of full-stack and am using this guide: How To Use MERN Stack: A Complete Guide | MongoDB
as a refresher.

I am having an issue after going through this code back and forth a couple times. Super simple but annoyingly evasive for the search engines.

The loadEnvironment.mjs file has the following code:


import dotenv from "dotenv";

VS Code kicks back the following:


ReferenceError: js is not defined

I am only copy pasting the code from the guide at this point because i’ve gone through the code and tried to figure it out myself.

commenting out or removing the ‘js’ line throws error:

MongoParseError('Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://" 

But my ATLAS_URI does in fact start with the latter and is copied from the Atlas UI that provides it.

I cannot go further by myself right now and get too frustrated with all the information search engines kick back that i cannot get to the bottom of such a seemingly simple question.

Thank you to anyone that sees this and helps.

Removing the js line is certainly the way to go.

As for the Invalid Scheme error it would be best if you share the code that uses the URI and the URI it self. If the URI is wrong we need to see it to know what is wrong with it.

May be you have other characters like spaces or quotes. Share the dotenv file.

I’d first like to thank you @steevej for responding. Having any feedback is great for me.

I did remove js and amongst other things I have sorted I am having trouble with the mongo atlas authentication now haha.

I will look into it more after work another day. I may have to open a new thread for a different question, not sure how forums works

thanks again!

1 Like

Hello Joe and Steve,

I have been using the same tutorial as Joe, and I am facing the exact same problem, the MongoParseError.

Hoping to get more help with this issue.