【问题标题】:Nest.js - nest cli is not picking up the latest file changesNest.js - 嵌套 cli 没有获取最新的文件更改
【发布时间】:2020-05-31 17:08:27
【问题描述】:

我写了一个非常基本的控制器,比如

@Controller('tasks')
export class TasksController {

  constructor(private tasksService: TasksService) {}

  @Get(':id')
  getById(@Param('id') id: string): TaskDto {
    console.log('Get Called>>>', id);
    const task = this.tasksService.getById(id);
    const dto = TaskMapper.toDto(task);

    return dto;
  }

  @Delete(':id')
  remove(@Param('id') id: string): void {
    console.log('Delete Called>>>', id);
    this.tasksService.remove(id);
  }
}

我正在使用以下 URI 通过 Postman(也尝试使用 Powershell)调用每个端点,并使用它们各自的 METHOD GET、DELETE。

http://localhost:3000/tasks/83b213a0-8cbf-46e0-a484-e3df7f216e2f

现在,最奇怪的是 CLI 莫名其妙地卡在了控制器文件的一个版本上。现在即使我删除了整个控制器,cli仍然在映射控制器的不同方法。

我尝试了通过各种 yarn、npm 和直接嵌套命令启动应用程序的不同方法,但似乎没有任何东西可以获取最新的文件更改。

我已经检查了整个代码无数次,但无法查明问题!

【问题讨论】:

    标签: nestjs


    【解决方案1】:

    终于让它工作了,解决方案是删除“dist”文件夹。

    但是我还是不明白为什么会出现这个问题!!

    【讨论】:

    • 或者,您可以在调用 >yarn start 之前运行 tsc.. 我目前有同样的问题
    • 同样的事情发生在我身上。如果有人有解释请回复或回答原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 1970-01-01
    相关资源
    最近更新 更多