I installed @nestjs/devtools-integration as a dev dependency. Now in production, I get the following error:
Cannot find module '@nestjs/devtools-integration'
// app.module.ts
import { Module } from '@nestjs/common';
import { DevtoolsModule } from '@nestjs/devtools-integration';
@Module({
imports: [DevtoolsModule.register()],
})
export class AppModule {}
Is there a way to mark it non-required based on NODE_ENV, and get past this error?
Tried the following but it doesn't work:
@Module({
imports: [
...(process.env.NODE_ENV !== 'production'
? []
: [
import('@nestjs/devtools-integration').then((devtools) => {
return devtools.DevtoolsModule.register({
http: process.env.NODE_ENV !== 'production',
});
}),
]),
],
})
export class AppModule {}
Also tried to catch the error with process.on('unhandledRejection', (error) => {}) but no luck.
The docs don't mention optional modules, is that not possible? What's the recommended approach here?