Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm 相对于 npm/yarn 的优势 #55

Open
nmsn opened this issue Oct 31, 2022 · 0 comments
Open

pnpm 相对于 npm/yarn 的优势 #55

nmsn opened this issue Oct 31, 2022 · 0 comments
Labels

Comments

@nmsn
Copy link
Owner

nmsn commented Oct 31, 2022

原文:https://zhuanlan.zhihu.com/p/352437367?v_p=90&WBAPIAnalysisOriUICodes=10000001&launchid=default&wm=3333_2001&aid=01A8IzwnkBcjd17Tl9KDHn1TwWzT3Trn8ayhN5c2NpgayRH5o.&from=10CA293010&utm_id=0

速度快

在 clean install、with cache、with lockfile、with node_modules 的各种安装情景下,相对于 npm、yarn(yarn PnP)都有明显速度优势

yarn PnP 模式
https://loveky.github.io/2019/02/11/yarn-pnp/

高效利用磁盘

pnpm 内部使用基于内容寻址的文件系统来存储磁盘上所有的文件,这个文件系统出色的地方在于

  • 不会重复安装同一个包,磁盘中只有一个地方写入,后面再次使用都会直接使用硬链接
  • 即使一个包的不同版本,pnpm 也会极大程度地复用之前版本的代码

支持 monorepo

pnpm 与 npm/yarn 另外一个很大的不同就是支持了 monorepo,体现在各个子命令的功能上,比如在根目录下 pnpm add A -r, 那么所有的 package 中都会被添加 A 这个依赖,当然也支持 --filter字段来对 package 进行过滤

安全性高(没有幻影依赖)

没有 npm/yarn 扁平化安装导致的幻影依赖问题

@nmsn nmsn added the npm label Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant