root 中的 typeormconfig 导致与 npm 运行 start:prod 脚本不兼容

typeormconfig in root causes incompatiblity with npm run start:prod script

我的 ormconfig.ts 在我的项目根目录中,我的 nest 应用程序位于 src 文件夹中,这似乎是使用 nest cli 生成项目后的默认文件夹。但是,在编译时,我的 dist 文件夹包含我的 src 文件夹,因此默认的 npm run start:prod 命令将不起作用,因为它指的是 dist/main 文件夹,而不是 dist/src/main。现在我可以通过多种方式解决这个问题,但我想知道以前是否有人遇到过这个问题。

距离:

ormconfig.ts
- src
-- modules
-- scripts
-- app.module.ts
-- main.ts

default start:prod nest cli 生成的命令: node dist/main

如果你想让 ormconfig 成为项目根目录中的 ts 文件,typescript 会将 js 文件移动到 dist 并保持你已有的相同目录结构。这意味着 src 目录将被保留,因为根目录中有一个 ts 文件。您可以更新 start:prod 命令以指向 dist/src/main 或者您可以使 ormconfig 不是 ts 文件