Search code examples
pnpm

Why is pnpm linking certain dependencies at the top level?


If I run :

pnpm install eslint

Then my node_modules directory ends up containing:

node_modules
  .bin/
  .pnpm/
  @eslint/eslintrc
  eslint
  eslint-scope
  eslint-utils
  eslint-visitor-keys
  .modules.yaml

I can't seem to find anything particularly special about eslint or its dependencies that would cause that, but maybe I'm not looking at the right place.

The only thing that makes sense is that pnpm is hoisting these dependencies at the top solely based on the fact that they are prefixed by the name of the package I actually installed. That really doesn't seem right though.

What am I missing here?


Solution

  • In case someone else hits that head-scratcher:

    The answer is simply that the default value of public-hoist-pattern contains *eslint*, so all eslint-related modules are special-cased.

    see: https://pnpm.io/npmrc#public-hoist-pattern