How to exclude `node_modules/@types/**/node_modules`?

前端 未结 2 1182
一向
一向 2021-01-18 12:04

I have run into a situation where a type definition in node_modules/@types is installing its own @types dependencies, and these \"nested\" @types conflict with

2条回答
  •  -上瘾入骨i
    2021-01-18 12:34

    Use peerDependencies to ensure you only have one version of a dependency.

    i.e. If I am using typings for angular and angular-mocks, angular-mocks will have its own @types/angular

    @types/angular  // => 1.5.8
    @types/angular-mocks // => 1.5.8
    @types/angular-mocks/node_modules/@types/angular // => *
    

    To prevent two version of @types/angular from being installed, declare @types/angular as a peerDependency in your package.json file.

提交回复
热议问题