【问题标题】:@nestjs/swagger install errors@nestjs/swagger 安装错误
【发布时间】:2021-10-14 06:09:13
【问题描述】:

目前,当我使用 yarn install 在我的 nestjs 项目上安装 swagger 时,出现以下错误。有什么想法可能导致这种情况吗?

src/ledger/dtos/addOrdersByDate.dto.ts:2:10 - 错误 TS2724:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiModel 属性'。您是说“ApiHideProperty”吗?

2 从“@nestjs/swagger”导入 { ApiModelProperty }; ~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25 1 导出声明函数ApiHideProperty():PropertyDecorator; ~~~~~~~~~~~~~~~ 'ApiHideProperty' 在这里声明。

src/ledger/dtos/addRebatesCharges.dto.ts:1:10 - 错误 TS2724:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiModel 属性'。您是说“ApiHideProperty”吗?

1 从“@nestjs/swagger”导入 { ApiModelProperty }; ~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25 1 导出声明函数ApiHideProperty():PropertyDecorator; ~~~~~~~~~~~~~~~ 'ApiHideProperty' 在这里声明。

src/ledger/dtos/addReturns.dto.ts:2:10 - 错误 TS2724:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiModel 属性'。您是说“ApiHideProperty”吗?

2 从“@nestjs/swagger”导入 { ApiModelProperty }; ~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25 1 导出声明函数ApiHideProperty():PropertyDecorator; ~~~~~~~~~~~~~~~ 'ApiHideProperty' 在这里声明。

src/ledger/dtos/addSellers.dto.ts:2:10 - 错误 TS2724:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiModel 属性'。您是说“ApiHideProperty”吗?

2 从“@nestjs/swagger”导入 { ApiModelProperty }; ~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25 1 导出声明函数ApiHideProperty():PropertyDecorator; ~~~~~~~~~~~~~~~ 'ApiHideProperty' 在这里声明。

src/ledger/dtos/block.dto.ts:2:10 - 错误 TS2724:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiModel 属性'。您是说“ApiHideProperty”吗?

2 从“@nestjs/swagger”导入 { ApiModelProperty }; ~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25 1 导出声明函数ApiHideProperty():PropertyDecorator; ~~~~~~~~~~~~~~~ 'ApiHideProperty' 在这里声明。

src/ledger/dtos/transaction.dto.ts:1:10 - 错误 TS2724:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiModel 属性'。您是说“ApiHideProperty”吗?

1 从“@nestjs/swagger”导入 { ApiModelProperty }; ~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25 1 导出声明函数ApiHideProperty():PropertyDecorator; ~~~~~~~~~~~~~~~ 'ApiHideProperty' 在这里声明。

src/queue/controllers/queue.controller.ts:2:10 - 错误 TS2305:模块 '"../../../node_modules/@nestjs/swagger"' 没有导出成员 'ApiUseTags'。

2 导入 { ApiUseTags, ApiOperation, ApiResponse } 从 '@nestjs/swagger'; ~~~~~~~~~~

src/queue/controllers/queue.controller.ts:10:19 - 错误 TS2345: '{ title: string; 类型的参数}' 不可分配给参数 “部分”类型。对象字面量只能指定 已知属性,并且类型中不存在“标题” '部分'。

10 @ApiOperation({ title: '列出消息数量的队列' }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/shared/controllers/configuration.controller.ts:2:24 - 错误 TS2305:模块 '"../../../node_modules/@nestjs/swagger"' 没有 导出成员“ApiUseTags”。

2 从 '@nestjs/swagger' 导入 { ApiOperation, ApiUseTags }; ~~~~~~~~~~

src/shared/controllers/configuration.controller.ts:12:19 - 错误 TS2345:类型参数 '{ 标题:字符串; }' 不可分配给 “部分”类型的参数。对象字面量可能 只指定已知属性,并且类型中不存在'title' '部分'。

12 @ApiOperation({ title: '获取配置变量' }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/shared/controllers/history.controller.ts:2:24 - 错误 TS2305: 模块 '"../../../node_modules/@nestjs/swagger"' 没有导出 成员“ApiUseTags”。

2 从 '@nestjs/swagger' 导入 { ApiOperation, ApiUseTags }; ~~~~~~~~~~

src/shared/controllers/history.controller.ts:10:19 - 错误 TS2345: '{ title: string; 类型的参数}' 不可分配给参数 “部分”类型。对象字面量只能指定 已知属性,并且类型中不存在“标题” '部分'。

10 @ApiOperation({ title: '获取实体的历史记录' }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/shared/filters/http-exception.filter.ts:24:34 - 错误 TS2339: 类型“字符串”上不存在属性“错误”。

24 错误:exception.message.error, ~~~~~

src/shared/filters/http-exception.filter.ts:25:36 - 错误 TS2339: “字符串”类型不存在属性“消息”。

25 消息:exception.message.message, ~~~~~~~

src/shared/filters/http-exception.filter.ts:35:34 - 错误 TS2339: 类型“字符串”上不存在属性“错误”。

35 错误:exception.message.error,

【问题讨论】:

    标签: node.js typescript swagger


    【解决方案1】:

    ApiModelProperty 更改为ApiProperty

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    【解决方案2】:

    swagger 包 4.0 版本的重大更改列表: https://docs.nestjs.com/openapi/migration-guide#breaking-changes

    我猜至少部分问题来自那里。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-19
      • 2021-09-20
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 2020-03-30
      • 1970-01-01
      相关资源
      最近更新 更多