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 是如何节约 node_modules 磁盘占用的 #10

Open
shhider opened this issue Jan 2, 2023 · 0 comments
Open

pnpm 是如何节约 node_modules 磁盘占用的 #10

shhider opened this issue Jan 2, 2023 · 0 comments

Comments

@shhider
Copy link
Owner

shhider commented Jan 2, 2023

之前知道 pnpm 是节约磁盘的,以为就是 packages 都下载到一个全局位置,各 project 的 deps 中直接 soft link(也没实际尝试

最近手头的 project 切换到 pnpm,install 后发现是在 project/node_modules 中有个 .pnpm 目录、其中是各 package 各版本,项目的 deps 则 soft link 到 .pnpm 中对应的 pkg。

这就引起我的疑惑:如此的话,当我要 re-install 时、直接删除整个 node_modules 目录,.pnpm 目录也被删了,再 install 时岂不是要重新下载?还是说我这 project 单独配置了要这样?

经过查找资料,发现这是 byDesign 的:看起来只是 project 的 deps 是 soft link 到 .pnpm 目录,但 .pnpm 中的 pkgs 的确是 link 到了全局的 pkgs 缓存,只是用了 hard link,直接 ls 命令罗列的内容无法一眼看出 hard link(实际上第二列、即权限列后的数字,就是 hard link 的数量)

reference:

https://javascript.plainenglish.io/what-is-pnpm-why-you-should-try-it-as-a-frontend-developer-69a3a7b34f5b

https://pnpm.io/faq#why-does-my-node_modules-folder-use-disk-space-if-packages-are-stored-in-a-global-store

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant