Tell us what’s happening:
When I try to submit my repl link, it says that it timed out. I think i have done everything else right but am currently quite frustrated!
(node:3001) UnhandledPromiseRejectionWarning: 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.
at NativeConnection.Connection.openUri (/home/runner/boilerplate-mongomongoose-1/node_modules/mongoose/lib/connection.js:669:11)
at /home/runner/boilerplate-mongomongoose-1/node_modules/mongoose/lib/index.js:342:10
at /home/runner/boilerplate-mongomongoose-1/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5
at new Promise (<anonymous>)
at promiseOrCallback (/home/runner/boilerplate-mongomongoose-1/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)
at Mongoose.connect (/home/runner/boilerplate-mongomongoose-1/node_modules/mongoose/lib/index.js:341:10)
at Object.<anonymous> (/home/runner/boilerplate-mongomongoose-1/myApp.js:3:10)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/runner/boilerplate-mongomongoose-1/server.js:67:16)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
(node:3001) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3001) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have a .env file, which was just called .env. I made a new one now called env.env (in case it was an issue to have nothing in front of the dot.
it contains the following (not worried about database security here tbh)
The only way I got it to work was to replace process.env.MONGO_URI with the actual uri, completely circumventing the env file. Even after i made a new file (ensuring there weren’t spaces between the = and everything) it did the same thing. Once i put the URI in app.js it worked fine!
As long as you have the .env file (named just that, nothing more) it really should work.
I don’t think repl reinstalls packages when you fork something, but just in case, I might try removing the dotenv package and then re-install it, just to test it.
I don’t really know what else to suggest. Other than forking the starter project again, or even forking your own project, just to test a copy.
It would be nice to know why this is happening but I guess it’s not that important as long as you can complete the challenges somehow.