Error while running nestjs in production mode, cannot find module Error while running nestjs in production mode, cannot find module typescript typescript

Error while running nestjs in production mode, cannot find module


I have found the issue, it was because of absolute path while importing the class.

import { EntityService } from '../shared/service-common'; //correct wayimport { EntityService } from 'src/shared/service-common'; // wrong autoimport

To fix auto import, I have added this setting in VS Code

"typescript.preferences.importModuleSpecifier": "relative"


Delete the dist directory and run again with npm run start:dev


I've also seen the same problem due to a capitalized reference, when the filename is lowercase:

import { SomeClass } from './Some.class'; 

but the file was named some.class.ts

Fixing the import resolved the error.