Skip to content

Commit a1fa97d

Browse files
committed
docs: add note about EMS to enableGlobalVirtualStore
1 parent d276c23 commit a1fa97d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/settings.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,18 @@ In the central virtual store, each package is hard linked into a directory whose
419419

420420
Using a global virtual store can significantly speed up installations when a warm cache is available. However, in CI environments (where caches are typically absent), it may slow down installation. If pnpm detects that it is running in CI, this setting is automatically disabled.
421421

422+
:::important
423+
424+
To support hoisted dependencies when using a global virtual store, pnpm relies on the `NODE_PATH` environment variable. This allows Node.js to resolve packages from the hoisted `node_modules` directory. However, **this workaround does not work with ESM modules**, because Node.js no longer respects `NODE_PATH` when using ESM.
425+
426+
If your dependencies are ESM and they import packages **not declared in their own `package.json`** (which is considered bad practice), you’ll likely run into resolution errors. There are two ways to fix this:
427+
* Use [packageExtensions] to explicitly add the missing dependencies.
428+
* Add the [@pnpm/plugin-esm-node-path] config dependency to your project. This plugin registers a custom ESM loader that restores `NODE_PATH` support for ESM, allowing hoisted dependencies to be resolved correctly.
429+
430+
:::
431+
432+
[packageExtensions]: #packageextensions
433+
[@pnpm/plugin-esm-node-path]: https://github.com/pnpm/plugin-esm-node-path
422434
[NixOS manages packages]: https://nixos.org/guides/how-nix-works/
423435

424436
## Store Settings

0 commit comments

Comments
 (0)