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?
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With