Error while running nestjs in production mode, cannot find module

后端 未结 4 1783
滥情空心
滥情空心 2021-02-07 07:12

I have implemented a generic class as below which might be causing the problem,

    import { Logger } from \'@nestjs/common\';
    import { PaginationOptionsInt         


        
相关标签:
4条回答
  • 2021-02-07 07:17

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

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

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

    "typescript.preferences.importModuleSpecifier": "relative"
    
    0 讨论(0)
  • 2021-02-07 07:19

    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.

    0 讨论(0)
  • 2021-02-07 07:31

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

    0 讨论(0)
  • 2021-02-07 07:41

    it caused by capitalized file Name.

    Key-store.entity.ts -> key-store.entity.ts
    

    make filename all to lowercase.

    0 讨论(0)
提交回复
热议问题