Node.js NestJS防止在开发中重新加载服务器

Node.js NestJS防止在开发中重新加载服务器,node.js,nestjs,Node.js,Nestjs,我有一个路由,它在public目录中创建一个新文件夹,这是一个与app.useStaticAssets一起提供的静态内容 问题是,即使我在tsconfig.build.json和tsconfig.json的exclude数组中添加了public目录,当在public目录中删除或创建新文件夹时,我的服务器仍在开发中重新加载 我错过了什么 更新: tsconfig.json { "compilerOptions": { "module": "commonjs", "declarat

我有一个路由,它在public目录中创建一个新文件夹,这是一个与app.useStaticAssets一起提供的静态内容

问题是,即使我在tsconfig.build.jsontsconfig.jsonexclude数组中添加了public目录,当在public目录中删除或创建新文件夹时,我的服务器仍在开发中重新加载

我错过了什么

更新: tsconfig.json

{
 "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "noImplicitAny": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "exclude": ["node_modules", "dist", "public"]
}

我提到,public文件夹在src文件夹之外。他们处于同一水平。

我能够重现这一点,并发现这似乎是一个常见问题->

正如github问题中所提出的,添加
include
作为解决方案似乎可以解决问题:

{
 "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "noImplicitAny": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist", "public"]
}

我能够重现这一点,并发现这似乎是一个常见的问题->

正如github问题中所提出的,添加
include
作为解决方案似乎可以解决问题:

{
 "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "noImplicitAny": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist", "public"]
}

如果要暂时完全禁用热重新加载,请从start:dev脚本中删除--watch标志

  • 进入package.json
  • 在“脚本”下找到“开始:开发”脚本
  • 复制“start:dev”脚本并将其重命名-我将其命名为
    start:dev noreload
    您的脚本应该如下所示:
  • “start:dev noreload”:“npm运行预构建和npm运行终止:开发进程和npm运行构建:docker postgres和&env env=dev nest start”

  • 使用

    npm运行开始:dev noreload

  • 为了恢复热加载,只需按正常方式运行即可。
    使用
    npm start
    ,或
    npm run start:dev

    如果要临时完全禁用热重新加载,请从start:dev脚本中删除--watch标志

  • 进入package.json
  • 在“脚本”下找到“开始:开发”脚本
  • 复制“start:dev”脚本并将其重命名-我将其命名为
    start:dev noreload
    您的脚本应该如下所示:
  • “start:dev noreload”:“npm运行预构建和npm运行终止:开发进程和npm运行构建:docker postgres和&env env=dev nest start”

  • 使用

    npm运行开始:dev noreload

  • 为了恢复热加载,只需按正常方式运行即可。
    请使用
    npm start
    ,或
    npm run start:dev

    添加
    tsconfig
    -文件的内容好吗?让我知道建议的解决方案是否有效,也许我们可以在github上打开另一张关于此问题的通知单。请添加
    tsconfig
    -文件的内容好吗?让我知道建议的解决方案是否有效,也许我们可以在github上再开一张关于这个问题的票。