Skip to main content
Version: 9.x

pnpm store

管理包存储。

¥Managing the package store.

命令

¥Commands

status

检查存储中是否有修改过的软件包。

¥Checks for modified packages in the store.

如果包的内容与解包时相同,则返回退出代码 0。

¥Returns exit code 0 if the content of the package is the same as it was at the time of unpacking.

add

功能与 pnpm add 相同,不同之处在于它直接将新包添加到存储,而不修改存储外部的任何项目或文件。

¥Functionally equivalent to pnpm add, except this adds new packages to the store directly without modifying any projects or files outside of the store.

prune

从存储中删除未引用的包。

¥Removes unreferenced packages from the store.

未引用的包是系统上任何项目都未使用的包。在大多数安装操作之后,例如当依赖变得多余时,包可能会变得不受引用。

¥Unreferenced packages are packages that are not used by any projects on the system. Packages can become unreferenced after most installation operations, for instance when dependencies are made redundant.

例如,在 pnpm install 期间,软件包 foo@1.0.0 更新为 foo@1.0.1。pnpm 会将 foo@1.0.0 保留在存储中,因为它不会自动删除包。如果系统上的任何其他项目未使用包 foo@1.0.0,则它将变为未引用状态。运行 pnpm store prune 将从存储中删除 foo@1.0.0

¥For example, during pnpm install, package foo@1.0.0 is updated to foo@1.0.1. pnpm will keep foo@1.0.0 in the store, as it does not automatically remove packages. If package foo@1.0.0 is not used by any other project on the system, it becomes unreferenced. Running pnpm store prune would remove foo@1.0.0 from the store.

运行 pnpm store prune 没有害处,并且对你的项目没有副作用。如果将来的安装需要删除的软件包,pnpm 将再次下载它们。

¥Running pnpm store prune is not harmful and has no side effects on your projects. If future installations require removed packages, pnpm will download them again.

最佳实践是偶尔运行 pnpm store prune 来清理存储,但不要太频繁。有时,未引用的包会再次被需要。当切换分支并安装较旧的依赖时可能会发生这种情况,在这种情况下,pnpm 需要重新下载所有已删除的软件包,从而短暂地减慢安装过程。

¥It is best practice to run pnpm store prune occasionally to clean up the store, but not too frequently. Sometimes, unreferenced packages become required again. This could occur when switching branches and installing older dependencies, in which case pnpm would need to re-download all removed packages, briefly slowing down the installation process.

请注意,当 存储服务器 运行时,该命令被禁止。

¥Please note that this command is prohibited when a store server is running.

path

返回活动存储目录的路径。

¥Returns the path to the active store directory.