__dirname被定位到了dist文件夹

来源:7-6 官方方案进阶:嵌套配置yaml文件读取

青铜Q

2023-11-10

const YAML_CONFIG_FILENAME = ‘config.yml’;
const filePath = join(__dirname, ‘…/config’, YAML_CONFIG_FILENAME);

[Nest] 17320 - 2023/11/10 17:26:09 ERROR [ExceptionHandler] ENOENT: no such file or directory, open ‘D:\studyspace\nest-demo\dist\apps\config\config.yml’

写回答

1回答

Brian

2023-11-13

你在运行的时候,nest会使用tsc把代码编译了之后,运行,所以会产生dist目录,也会在dist目录中运行入口文件,这块逻辑是没有问题的。

你看看是不是你写了三个点:

https://img1.sycdn.imooc.com/szimg/655206c809af04af11700202.jpg

0
0

NestJS 入门到实战 前端必学服务端新趋势

近几年快速发展的Node.js框架,掌握未来前端工程师后端开发能力

569 学习 · 238 问题

查看课程