Problem
I'm creating a Nest.js based app and until now everything went just fine. After changing the connection approach (using the `@nestjs/mongoose` package) from snippet1 to snippet2 below, the running app didn't reflect changes. It keeps connecting via a connection string that doesn't appear anywhere in the codebase.snippet1
imports: [
MongooseModule.forRoot(config.db.uri, { useFindAndModify: false }),
/* other imports */
],
snippet2
imports: [
MongooseModule.forRoot(config.db.uri, {
connectionFactory: (connection) => {
connection.plugin(accessibleRecordsPlugin);
return connection;
},
dbName: isInDevelomentMode(process.env.NODE_ENV) ? 'dev' : 'prod'
}),
/* other imports */
]
Regardless of the snippets above, even by updating only the JSON file containing the constant, the changes are not reflected and the app keeps connecting to the old one.
I read the string from the config.json file as following
import * as config from './config/config.json';
"db": {
"uri": "mongodb+srv://revo:<psw>@cluster0.ngr5j.mongodb.net/?retryWrites=true&w=majority",
"defaultUpdateOptions": {
"new": true
}
}
What I've tried
- Deleting
distfolder then re-runningnpm run start:dev - Deleting
node_modulesfolder then re-runningnpm iandnpm run start:dev - Running the app via
npm run build && npm run startas mentioned in Nest.Js not accepting any changes