yarn-workspacespnpmnpm-workspacespnpm-workspace

pnpm: Disable sharing executables between projects in monorepo


I have a classic pnpm monopero with two packages: a and b.

The package a has the eslint package as a dependency. The package b has not.

The problem is that when you are in the b package folder and run pnpm exec eslint there are no errors and pnpm used eslint from the package a.

  1. Is it correct?
  2. Can I disable this behaviour?
  3. Do other package managers have the same behavior?

Solution

  • This happens because by default pnpm hoists any packages with "eslint" in the name. It is done because eslint's plugin system doesn't work well with pnpm if the packages are not hoisted.

    If you don't want this behavior, you can change the value of public-hoist-pattern by adding an .npmrc in the root of your monorepo:

    public-hoist-pattern[]=