6

When I run the debugger in vscode I get this error:

MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.

I realized this was because the debugger isn't getting access to my .env file. My database uri is stored in my .env file. So the debugger can't see it.

How can I give my debugger access to the my .env file variables?

1 Answer 1

12

I fixed it by adding this to my launch.json file in my .vscode workspace folder. I added two values to the configurations object:

"env": { "PORT": "4000" },
"envFile": "${workspaceFolder}/backend/.env"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.