包管理器 - peer dependency 的安装

npm 和 yarn 安装依赖(包)时不会自动安装 peer dependence(虽然很旧的 npm 是会自动安装的,但几乎没人用那么旧的了),而是给出如下警告:

$ npm install --save-dev rollup-plugin-typescript
npm WARN [email protected] requires a peer of tslib@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.1.0 but none is installed. You must install peer dependencies yourself.

$ yarn add -D rollup-plugin-typescript
yarn add v1.13.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "tslib@*".
warning " > [email protected]" has unmet peer dependency "typescrip
t@>=2.1.0".

并且也没有自动安装 peer dependence 选项,这也就是为什么我们安装某些依赖时需要同时安装多个依赖(包),例如:npm install --save-dev rollup-plugin-typescript typescript tslib

同时也应该注意安装时的警告(warning)!!!

参考:

  • Peer Dependencies | Node.js
  • peerDependencies | Introduction
  • Types of dependencies | Yarn

转载于:https://www.cnblogs.com/jffun-blog/p/10566116.html

你可能感兴趣的:(包管理器 - peer dependency 的安装)