NestJS server with mongoose fails on deploy

I have a NestJS server application. It runs perfectly on local. I have a remote MongoDB which I connect to using @nestjs/mongoose module. Added an environment variable DB_URL (tried locally using the remote db connection string and it works)

When I build and start the application on render, it builds successfully. But the start command fails with the error.

 Error: Nest can't resolve dependencies of the mongodb+srv://***:****@cluster0.wxhrnig.mongodb.net/inventoryConnection/PartModel (?). Please make sure that the argument mongodb+srv://***:****@cluster0.wxhrnig.mongodb.net/inventoryConnection at index [0] is available in the MongooseModule context.
Sep 24 12:20:41 PM  
Sep 24 12:20:41 PM  Potential solutions:
Sep 24 12:20:41 PM  - Is MongooseModule a valid NestJS module?
Sep 24 12:20:41 PM  - If mongodb+srv://***:****@cluster0.wxhrnig.mongodb.net/inventoryConnection is a provider, is it part of the current MongooseModule?
Sep 24 12:20:41 PM  - If mongodb+srv://***:****@cluster0.wxhrnig.mongodb.net/inventoryConnection is exported from a separate @Module, is that module imported within MongooseModule?
Sep 24 12:20:41 PM    @Module({
Sep 24 12:20:41 PM      imports: [ /* the Module containing mongodb+srv://***:****@cluster0.wxhrnig.mongodb.net/inventoryConnection */ ]
Sep 24 12:20:41 PM    })
Sep 24 12:20:41 PM  
Sep 24 12:20:41 PM      at Injector.lookupComponentInParentModules (/opt/render/project/src/node_modules/@nestjs/core/injector/injector.js:254:19)
Sep 24 12:20:41 PM      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Sep 24 12:20:41 PM      at async Injector.resolveComponentInstance (/opt/render/project/src/node_modules/@nestjs/core/injector/injector.js:207:33)
Sep 24 12:20:41 PM      at async resolveParam (/opt/render/project/src/node_modules/@nestjs/core/injector/injector.js:128:38)
Sep 24 12:20:41 PM      at async Promise.all (index 0)
Sep 24 12:20:41 PM      at async Injector.resolveConstructorParams (/opt/render/project/src/node_modules/@nestjs/core/injector/injector.js:143:27)
Sep 24 12:20:41 PM      at async Injector.loadInstance (/opt/render/project/src/node_modules/@nestjs/core/injector/injector.js:70:13)
Sep 24 12:20:41 PM      at async Injector.loadProvider (/opt/render/project/src/node_modules/@nestjs/core/injector/injector.js:97:9)
Sep 24 12:20:41 PM      at async /opt/render/project/src/node_modules/@nestjs/core/injector/instance-loader.js:56:13
Sep 24 12:20:41 PM      at async Promise.all (index 3)
Sep 24 12:20:41 PM  error Command failed with exit code 1.
Sep 24 12:20:41 PM  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What am I doing wrong? Same configuration works locally so I’m wondering if there is some setting that I’m missing?

This user was responded to in a private ticket.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.