[英]How to exclude package from being installed via symlink in pnpm?
I have an Electron project and used pnpm
due to it's significant speedup when installing modules over npm
or yarn
.我有一个 Electron 项目并使用了pnpm
因为它在通过npm
或yarn
安装模块时显着加速。
However, 1 module has a problem by being installed via a symlink in the node_modules
directory.但是,通过node_modules
目录中的符号链接安装1模块存在问题。 Is there any way to exclude a dependency from becoming a symlink?有没有办法排除依赖项成为符号链接?
As far as I understood the documentation, a .npmrc
file with the setting below should be enough, but it doesn't work:据我了解文档,具有以下设置的.npmrc
文件应该足够了,但它不起作用:
hoist-pattern[]=*nodegit*
As of version 5.14, the only way to avoid symlinks with pnpm is to use the Plug'n'Play feature and set the symlink setting to false.从 5.14 版开始,避免使用pnpm 进行符号链接的唯一方法是使用即插即用功能并将符号链接设置为 false。 You can create a .npmrc
in the root of you project with the following content:您可以在项目的根目录中创建一个.npmrc
以下内容的.npmrc
:
node-linker=pnp
symlink=false
Using the hoist settings you can only reduce the number of symlinks, not avoid them.使用提升设置只能减少符号链接的数量,而不能避免它们。 This blog post should explain the different configurations: Node-Modules configuration options with pnpm .这篇博文应该解释不同的配置: Node-Modules configuration options with pnpm 。 With hoist=false
, you'll get the minimal amount of symlinks.使用hoist=false
,您将获得最少的符号链接。
Plug'n'Play is known to still have lots of issues, so if it doesn't help, feel free to ask for help in the pnpm discord channel or create an issue in our repository .众所周知,即插即用仍然存在很多问题,因此如果它没有帮助,请随时在pnpm discord 频道中寻求帮助或在我们的存储库中创建问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.