package.json 的开放式对等版本依赖项?

Posted

技术标签:

【中文标题】package.json 的开放式对等版本依赖项?【英文标题】:Open ended peer version dependency for package.json? 【发布时间】:2018-08-24 23:06:52 【问题描述】:

总结

我假设@angular/core 的所有主要版本都适用于此。我应该将包对等依赖项指定为:

"peerDependencies": 
  "@angular/core": "x.x"

上下文

我正在为将在 NPM 上发布的 Angular 服务创建一个包。该模块仅包含一组适用于任何版本的 angular 的缓动函数。下面包含简要的 sn-p 以供参考。如您所见,服务从@angular/core 导入Injectable。我假设它对主要版本 5、6、7 等同样有效。

import Injectable from '@angular/core';

@Injectable()
export class RoundProgressEase 
  // t: current time (or position) of the neonate. This can be seconds or frames, steps,
  // seconds, ms, whatever – as long as the unit is the same as is used for the total time.
  // b: beginning value of the property.
  // c: change between the beginning and destination value of the property.
  // d: total time of the neonate.

  linearEase(t: number, b: number, c: number, d: number): number 
    return c * t / d + b;
  ;

  easeInQuad(t: number, b: number, c: number, d: number): number 
    return c * (t /= d) * t + b;
  ;

【问题讨论】:

【参考方案1】:

如果您想要一个开放式范围,请使用星号 (*)

"peerDependencies": 
  "@angular/core": "*"

【讨论】:

以上是关于package.json 的开放式对等版本依赖项?的主要内容,如果未能解决你的问题,请参考以下文章

Monorepo 中的对等依赖关系

如何识别哪些 npm 包只是对等依赖项?

通过阅读 package.json 升级 React 版本及其依赖项

全局安装具有对等依赖关系的 npm 包(package.json 中未提及)

在 package.json 中相同依赖项的 2 个版本之间切换的好方法?

如何使用 npm install 或 yarn 仅安装具有自己版本的 package.json 依赖项