我正在构建一个基于 Nestjs 的 API。这main.ts
文件嵌套在 my 的子文件夹中src
目录。结果,编译后的文件也嵌套在dist
目录和我的入口点是dist/api/main.js
代替dist/main.js
。我希望保持这种状态。
当启动我的应用程序时npm run start:dev
,我收到以下错误:
4:47:32 PM - Found 0 errors. Watching for file changes.
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module '/home/ymonb/Nest.js/myProject/dist/main'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
我需要能够使用新路径重新配置 Nest。我调查了文档 https://docs.nestjs.com/cli/usages#nest-start,但我没有看到任何指定不同入口点的内容。
我想也许我需要编辑nest-cli.json
,但我在该文件中找不到任何有关可能选项的文档(如果您知道此类文档,我很感兴趣!)。
这是我的nest-cli.json
:
{
"collection": "@nestjs/schematics",
"sourceRoot": "src/api"
}
任何想法?
您可以像这样编辑nest-cli.json:
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"entryFile": "your/main/js/path"
}
Nest-cli 将加载:your/main/js/path.js
我在源代码中找到了配置。Nest-cli/lib/configuration/configuration.ts https://github.com/nestjs/nest-cli/blob/master/lib/configuration/configuration.ts
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)