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

Viewed 1297

I have an Electron project and used pnpm due to it's significant speedup when installing modules over npm or yarn.

However, 1 module has a problem by being installed via a symlink in the node_modules directory. 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:

hoist-pattern[]=*nodegit*
1 Answers

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. You can create a .npmrc in the root of you project with the following content:

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. With hoist=false, you'll get the minimal amount of symlinks.

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.

Related