当我启动嵌套应用程序时,它会成功启动并显示下面给出的日志。
我已使用命令npm run dev:start
启动该项目。
[11:55:17 AM] File change detected. Starting incremental compilation...
[11:55:17 AM] Found 0 errors. Watching for file changes.
[Nest] 23860 - 05/19/2021, 11:55:18 AM [NestFactory] Starting Nest application...
[Nest] 23860 - 05/19/2021, 11:55:18 AM [InstanceLoader] AppModule dependencies initialized +106ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [InstanceLoader] TypeOrmCoreModule dependencies initialized +24ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [RouterExplorer] Mapped {/auth/signup, POST} route +2ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [RoutesResolver] PostController {/post}: +1ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [RouterExplorer] Mapped {/post/create, POST} route +0ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [RouterExplorer] Mapped {/post, GET} route +1ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [RoutesResolver] CategoryController {/category}: +0ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [RouterExplorer] Mapped {/category/create, POST} route +0ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [NestApplication] Nest application successfully started +2ms
[Nest] 23860 - 05/19/2021, 11:55:18 AM [bootstrap] Application started at localhost:5001
现在,如果我向端点发送任何请求,它会成功地发送请求,数据会存储在数据库中,还会返回数据,但问题是代码会被重新编译,并在控制台中显示
[12:06:59 PM] File change detected. Starting incremental compilation...
并且它不显示日志消息。我该怎么解决这个问题?
添加到您的tsconfig.json
:
"include": [
"src"
]
如果以上不起作用,以下是我如何修复问题
这与你的操作系统(在我的情况下是Windows 11(和ts 4.9 有关
请在包.json include 中使用typescript 4.8进行尝试
"devDependencies": {
...,
"typescript": "4.8.3",
...
}
后期
npm i
npm run start:dev
这可能会帮助您:https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#file-观察的变化
如Windows操作系统中Typescript版本9+的NestJs文档中所述,我们需要在tsconfig文件中的compilerOptions之后添加以下内容:
"watchOptions":{"watchFile":"固定轮询间隔";}
如果以上不起作用,以下是我如何修复问题
对于NestJS
在:tsconfig.build.json文件中
添加";包括":["./src"]
看起来像这个
tsconfig.build.json
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
"include": ["./src"]
}
我不知道是哪个依赖关系导致了我的问题。但对我来说,它只是在我跑步后起作用:
npm audit fix