Tell us what’s happening:
I have passed all of the previous tests just fine, but I can’t seem to pass this one. I tried everything, and eventually even tried copy-pasting the official solution on this forum, and even that doesn’t work.
In the code below, I’ve placed the console.log(“hmm”) and console.log(data) on purpose, and neither those, nor the console.error(err) error logs ever run. All I ever get is the GET request made by freeCodeCamp on my terminal, and after a while, the following timeout error on the freeCodeCamp challenge page:
// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed
The strange thing is I’m not getting anything at all, neither in the logs, nor in the terminal. All I get is the GET request once I run the tests, and nothing but.
I managed to get an error by running
node server.js
in the terminal, trying to manually launch the server:
$ node server.js
events.js:174
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1270:14)
at listenInCluster (net.js:1318:12)
at Server.listen (net.js:1405:7)
at Function.listen (/rbd/pnpm-volume/dc72d3c0-1652-4885-9c4f-6b01872527fb/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/app/server.js:344:20)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
at emitErrorNT (net.js:1297:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
With Glitch, you should not have a need to start/restart the server through the terminals.
If you do, choosing the correct ports becomes important.
Many campers have had issues using Glitch for the projects, just due to stability reasons, as well as the specific way Glitch handles the virtual servers.
So, I suggest you use the link in the README.md file to create a new project in Repl.it, and copy-pasta the code over.
file. While I created one for myself, only containing the MONGO_URI key and its value, I noticed that when I access process.env from the the myApp.js file, it was accessing a totally different one, with many different keys, except for the one I created.
To solve this issue, I unfortunately had to forego the usage of the .env file entirely and just wrote my credentials inside the myApp.js file.
I have a feeling that maybe there is an invisible .env file lurking somewhere, which I can’t see? If this isn’t just an issue on my end, it could be worthwhile to look into these, so others do not get confused either.
Anyhow, thank you for your quick responses, really appreciate your support.