Что делать, если зависимости npm @types создают конфликт в TypeScript?

Стоит мне сделать npm i, как у меня сразу появляется куча ошибок, которые начинаются так:

node_modules/@types/connect-mongo/node_modules/@types/mongoose/index.d.ts:77:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: NativeBuffer, NativeDate, NativeError, Mongoose, CastError, ConnectionBase, Connection, ValidationError, Error, VirtualType, Schema, MongooseDocument, Subdocument, Array, DocumentArray, Buffer, ObjectIdConstructor, Decimal128, Embedded, Query, DocumentQuery, mquery, Aggregate, SchemaType

77 declare module "mongoose" {
   ~~~~~~~

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

node_modules/@types/connect-mongo/node_modules/@types/mongoose/index.d.ts:703:48 - error TS2314: Generic type 'HookAsyncCallback<T>' requires 1 type argument(s).

703     pre(method: string, parallel: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): this;
                                                   ~~~~~~~~~~~~~~~~~

node_modules/@types/connect-mongo/node_modules/@types/mongoose/index.d.ts:704:29 - error TS2314: Generic type 'HookSyncCallback<T>' requires 1 type argument(s).

704     pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): this;
                                ~~~~~~~~~~~~~~~~

node_modules/@types/connect-mongo/node_modules/@types/mongoose/index.d.ts:766:13 - error TS2428: All declarations of 'HookSyncCallback' must have identical type parameters.

766   interface HookSyncCallback {
                ~~~~~~~~~~~~~~~~

node_modules/@types/connect-mongo/node_modules/@types/mongoose/index.d.ts:770:13 - error TS2428: All declarations of 'HookAsyncCallback' must have identical type parameters.

770   interface HookAsyncCallback {
                ~~~~~~~~~~~~~~~~~

node_modules/@types/mongoose/index.d.ts:48:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: NativeBuffer, NativeDate, NativeError, Mongoose, CastError, ConnectionBase, Connection, ValidationError, Error, VirtualType, Schema, MongooseDocument, Subdocument, Array, DocumentArray, Buffer, ObjectIdConstructor, Decimal128, Embedded, Query, DocumentQuery, mquery, Aggregate, SchemaType

48 declare module "mongoose" {
   ~~~~~~~


Стоит мне удалить директорию
/node_modules/@types/connect-mongo/node_modules/@types
, как всё прекрасно работает. Как правильно решить эту проблему?

Версия npm - 6.4.1, версия node - v8.11.4.
  • Вопрос задан
  • 1160 просмотров
Пригласить эксперта
Ответы на вопрос 1
@L2jLiga
Достаточно убедиться, что lдиапазоны версий @types/mongoose в @types/connect-mongo и в вашем проекте являются совместимыми

Как вариант решения в своем package json указать
"@types/mongoose": "*"
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы