常见问题
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 the project's node_modules
folders. 硬链接指向磁盘上原始文件所在的同一位置。 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.
获取有关此主题的更多信息:
- Why do hard links seem to take the same space as the originals?
- A thread from the pnpm chat room
- An issue in the pnpm repo
能用于Windows吗?
短回答:当然 长答案:在 Windows 上使用符号链接至少可以说是有问题的,但是,pnpm 有一个解决方法。 For Windows, we use junctions instead.
But the nested node_modules
approach is incompatible with Windows?
Early versions of npm had issues because of nesting all node_modules
(see
this issue). 但是,pnpm 不会创建深层文件夹,它使用符号链接来创建依赖关系树结构。
循环 symlinks 呢?
Although pnpm uses linking to put dependencies into node_modules
folders,
circular symlinks are avoided because parent packages are placed into the same
node_modules
folder in which their dependencies are. So foo
's dependencies
are not in foo/node_modules
, but foo
is in node_modules
together with its
own dependencies.