Skip to content

pnpm install --prod not removing hoisted dev dependencies #9782

@samchungy

Description

@samchungy

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

10.13.1

Which area(s) of pnpm are affected? (leave empty if unsure)

Dependencies resolver

Link to the code that reproduces this issue or a replay of the bug

https://github.com/samchungy/pnpm-hoist

Reproduction steps

1. Run pnpm install
2. Look at node_modules with hoisted eslint, typescript and prettier
3. Run pnpm install --prod
4. Look at node_modules with hoisted eslint, typescript and prettier

Describe the Bug

Looks like the --prod flag doesn't remove hoisted packages anymore. I only noticed when looking at my prod docker images and noticed some dev deps still in the image.

Expected Behavior

Running pnpm install --prod should remove hoisted dependencies.

I traced this change down to version 9.11 of pnpm, 9.10 seems to remove the hoisted deps.

Which Node.js version are you using?

22.14.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions