Reputation: 2658
I am using Nest.js to develop a web backend.
When I use npm run build
, the cmd shows success.
But when I use node dist/main.js
, the cmd shows error. But I'm sure this file exist and in develop mode (npm run start)
, everything's ok.
This is github address. https://github.com/Eve-1995/Oreo/tree/master/oreo-back-end
What should I do next?
Upvotes: 0
Views: 2157
Reputation: 216
You probably just need to add this in your tsconfig.json
:
"paths": {
"src/*": ["./src/*"]
}
TS can now correctly transform the src/
alias import when building the project.
Upvotes: 0
Reputation: 743
entities: [__dirname + '/../**/**/!(*.d).entity.{ts,js}'],
is doing the trick for me both in production and dev envs.
Upvotes: 2
Reputation: 869
I think the reason is in TypeOrm config.
@Module({
imports: [
AuthModule,
ClassificationModule,
ArticleModule,
UserModule,
CommentModule,
FragmentModule,
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
// logging: ["query"],
port: 3306,
username: 'root',
password: '123456',
database: 'myblog',
entities: ['src/**/**.entity{.ts,.js}'], // <-- replace it to 'dist/**/**.entity.js' in prod mode or use relative path
synchronize: true,
}),
],
})
export class AppModule { }
Upvotes: 2