Title: Issue Completing First Lesson Test on GitPod
Hello everyone,
I’ve successfully completed the first lesson test on Replit, but I’m unable to do the same on GitPod despite following the same steps.
I’ve:
Created a .env file with the MongoDB connection string.
Added the necessary code to myApp.js for database connection.
Ran npm run start.
On GitPod, the server port seems to be in use, or the connection isn’t recognized. Any help would be appreciated!
i wonder if this is because on gitpod you need the dotenv package?
I recall that in the basic node and express project, the instructions would remind us to:
If you are working locally, you will need the dotenv package. It loads environment variables from your .env file into process.env. The dotenv package has already been installed, and is in your project’s package.json file. At the top of your myApp.js file, add require('dotenv').config() to load the environment variables.)
So maybe worth a try to require the dotenv package in your code for this other project too.
“require(‘dotenv’).config()” is already in my myApp.js file, so I didn’t need to add it. When I restart my GitPod workspace, the test passes. It seems that the server on GitPod needs extra time to execute the code.
Anyway, thank you for replying and helping me!