pnpm - node_modules 目录是否在磁盘中占用相同的 space?
pnpm - Do node_modules directories occupy the same space in disk?
我有多个 Vue.js 项目分布在我笔记本电脑的文件系统中。我已经搜索并找到了 pnpm 的 npm node_modules
文件夹大小问题的解决方案。安装了 pnpm i
的项目依赖后,node_modules
文件夹的大小仍然表示它在每个项目中占用 space 233 MB。我只是想知道是否所有这些项目的 node_modules
文件夹都使用相同的 233 MB 硬盘 space 假设所有项目都具有相同的依赖关系。
是的,所有这些项目的 node_modules
使用相同的 233 MB 磁盘 space。
Why does my node_modules folder use disk space if packages are stored in a global store?
pnpm creates hard links from the global store to project's node_modules folders. Hard links point to the same place on the disk where the original files are. So, for example, if you have foo in your project as a dependency and it occupies 1MB of space, then it will look like it occupies 1MB of space in the project's node_modules folder and the same amount of space in the global store. However, that 1MB is the same space on the disk addressed from two different locations. So in total foo occupies 1MB, not 2MB.
For more on this subject:
我有多个 Vue.js 项目分布在我笔记本电脑的文件系统中。我已经搜索并找到了 pnpm 的 npm node_modules
文件夹大小问题的解决方案。安装了 pnpm i
的项目依赖后,node_modules
文件夹的大小仍然表示它在每个项目中占用 space 233 MB。我只是想知道是否所有这些项目的 node_modules
文件夹都使用相同的 233 MB 硬盘 space 假设所有项目都具有相同的依赖关系。
是的,所有这些项目的 node_modules
使用相同的 233 MB 磁盘 space。
Why does my node_modules folder use disk space if packages are stored in a global store?
pnpm creates hard links from the global store to project's node_modules folders. Hard links point to the same place on the disk where the original files are. So, for example, if you have foo in your project as a dependency and it occupies 1MB of space, then it will look like it occupies 1MB of space in the project's node_modules folder and the same amount of space in the global store. However, that 1MB is the same space on the disk addressed from two different locations. So in total foo occupies 1MB, not 2MB.
For more on this subject: