如何排除通过 pnpm 中的符号链接安装包?

How to exclude package from being installed via symlink in pnpm?

我有一个 Electron 项目并使用了 pnpm,因为它在 npmyarn.

上安装模块时速度显着加快

但是,1 模块在通过 node_modules 目录中的符号链接安装时存在问题。有什么方法可以排除依赖项成为符号链接吗?

据我对文档的理解,具有以下设置的 .npmrc 文件应该足够了,但它不起作用:

hoist-pattern[]=*nodegit*

从 5.14 版开始,避免 pnpm 符号链接的唯一方法是将 Plug'n'Play feature and set the symlink 设置为 false。您可以在项目的根目录中创建一个 .npmrc,内容如下:

node-linker=pnp
symlink=false

使用提升设置只能减少符号链接的数量,而不能避免它们。这篇博客 post 应该解释不同的配置:Node-Modules configuration options with pnpm。使用 hoist=false,您将获得最少数量的符号链接。

众所周知,即插即用仍然存在很多问题,所以如果它没有帮助,请随时在 pnpm discord channel or create an issue in our repository.

中寻求帮助