gpt4 book ai didi

node.js - 错误 TS6200 & 错误 TS2403 : Definitions of the following identifiers conflict with those in another file

转载 作者:行者123 更新时间:2023-12-03 12:13:22 30 4
gpt4 key购买 nike

我正在尝试在 typescript 中设置一个 Node 项目。
两个导致错误的文件:

  • node_modules@types\mongoose\index.d.ts
  • node_modules\mongoose\index.d.ts

  • [错误][1]
    [1]:/image/46vDU.jpg
    node_modules/@types/mongoose/index.d.ts:79:1 - 错误 TS6200:以下标识符的定义与另一个文件中的标识符冲突:DocumentDefinition、FilterQuery、UpdateQuery、NativeError、Mongoose、CastError、ConnectionOptions、Collection、Connection、已断开连接、已连接、正在连接、断开连接、未初始化、错误、QueryCursor、VirtualType、Schema、SchemaTypeOpts、Subdocument、Array、DocumentArray、Buffer、ObjectIdConstructor、Decimal128、Map、Aggregate、SchemaType、Document、ModelUpdateOptions
    79 声明模块“ Mongoose ”{

    node_modules/mongoose/index.d.ts:1:1
    1 declare module "mongoose" {
    ~~~~~~~
    Conflicts are in this file.

    node_modules/@types/mongoose/index.d.ts:226:14 - error TS2403: Subsequent variable declarations must have the same type. Variable 'SchemaTypes' must be of type 'typeof Types', but here has type 'typeof Types'.

    226 export var SchemaTypes: typeof Schema.Types;
    ~~~~~~~~~~~



    最佳答案

    Mongoose 包含自 mongoose@5.11.0 以来的 TypeScript 类型,因此您可以删除包 @types/mongoose .
    来源:https://developer.mongodb.com/community/forums/t/schema-error-while-running-backend-server-nestjs-angular/12440/3

    关于node.js - 错误 TS6200 & 错误 TS2403 : Definitions of the following identifiers conflict with those in another file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65353067/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com