Are .env files broken at Repl.it?

This is not my first time posting here about an .env file that is not working properly. I’m doing the Implement the Serialization of a Passport User challenge in the Quality Assurance - Advanced Node and Express Cert.

I’m getting this error when running the server:

MongoParseError: URI malformed, cannot be parsed

I’ve followed the steps in this post with the same issue: MongoParseError: URI malformed, cannot be parsed and still the same.

I’m also getting this in the console:

express-session deprecated req.secret; provide secret option

Error: secret option required for sessions

This is my .env file, which as far as I know it is correct:

PORT=8080
NODE_ENV=development
MONGO_URI=mongodb+srv://boss:freecodecamprules@cluster0.ovatf.mongodb.net/dbname?retryWrites=true&w=majority
SESSION_SECRET=shhhh

Link to the project: :arrow_upper_right:

(I had to delete the sample.env file that came with the boilerplate because Replit didn’t allow me to rename it to .env and add a new file named .env)

Hey, there.

Repl.it have been doing a lot of changes, recently. This could have affected the way .env files are used. However, it should still be possible to access the contents of a .env file via process.env, with the dotenv package.

So, provided you have followed the instructions, and have this at the top of your file:

'use strict';
require('dotenv').config();

I have not experienced any issues with .env in Repl.

I am not sure why you would need to do this. Typically, you can just copy the sample.env (it is not used by the system)

Hope you can get this sorted.


@Catalactics This is quite a different problem.

1 Like

Thank you very much again for your time. I will look into it, hopefully it has been fixed.