Hi there,
I am trying to solve the Install and Set Up Mongoose challenge from MongoDB and Mongoose chapter of the Back End Development and APIs course.
To create my DB cluster I followed this tutorial here :
I have created the MONGO_URI env variable using Replit SECRETS tab.
I have added these line in the myApp.js file in order to connect the DB :
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);
Finally in my package.json file I have the following dependencies :
"dependencies": {
"body-parser": "^1.15.2",
"dotenv": "^8.2.0",
"express": "^4.12.4",
"mongodb": "^3.3.2",
"mongoose": "^5.11.15"
},
When I run the code, I get the following error :
Error: Cannot find module ‘/home/runner/boilerplate-mongomongoose/index.js’
Require stack:
- /nix/store/29fdcv1yhlll61ml8a31qdkrbprxd7gs-prybar-nodejs-0.0.0-67f7a00/prybar_assets/nodejs/module-context-hook.js
- /tmp/prybar-nodejs-748972092.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Function.resolve (node:internal/modules/cjs/helpers:109:19)
Do you have any idea how to fix this ? (I already tried to open the .replit file as it is suggested in some other topics about the “Error: Cannot find module”)
Thanks in advance !