pnpm: `pnpm install --filter` (to install dependencies only for selected workspace projects) not working with `dedupe-peer-dependents` set to `true`
pnpm version:
- problem present in 8.0.0 with
dedupe-peer-dependentsnot set (thustrue= default value of v8.0.0) - problem not present in 8.0.0 with
dedupe-peer-dependentsset tofalse
Code to reproduce the issue:
https://github.com/pkerschbaum/pnpm-issue-workspaces-no-filter-applied-for-install
Expected behavior:
pnpm install --filter "package-a" should only install dependencies of workspace project package-a.
Actual behavior:
It installs all dependencies.
I tried to also clean the pnpm store before (rm -rf $(pnpm store path)) because I thought maybe pnpm installs more dependencies when they are on the machine already in the store, but even then all dependencies get downloaded&installed.

Additional information:
node -vprints: v16.19.0- Windows, macOS, or Linux?: Ubuntu 22.04.1 LTS
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 49
- Comments: 36 (9 by maintainers)
Commits related to this issue
- docs(docker): note about a bug https://github.com/pnpm/pnpm/issues/6300 — committed to pnpm/pnpm.io by KSXGitHub 3 years ago
- fix: installation with filtering and dedupe-peer-dependents=true close #6300 — committed to pnpm/pnpm by zkochan 2 years ago
- fix: installation with filtering and dedupe-peer-dependents=true (#8270) close #6300 — committed to FairyWorld/devtool_pnpm by zkochan 2 years ago
- fix: installation with filtering and dedupe-peer-dependents=true (#8270) close #6300 — committed to pnpm/pnpm by zkochan 2 years ago
As a dirty workaround, you can delete folders of unwanted packages before installing in your CI/CD. It’s not too bad in a simple monorepo where you have client/server/shared code, for instance. I delete the server folder before the client install, and I delete the client folder before the server install.
@osdiab FYI
--config.dedupe-peer-dependents=falsewould work as same effect.I’ve also noticed that setting
node-linker=hoistedalso installs all dependencies even whendedupe-peer-dependentsis set tofalse.🚢 9.5.0-beta.3
These issues should be solved if we do this change: https://github.com/pnpm/pnpm/issues/8165
UPD: missed that
--filterallows you to select dependencies also. Using-F project...solves my problem.pnpm -F <project> --config.dedupe-peer-dependents=false iworks fine if projects only depends on packages from NPM registry. If project depends on local packages (i.e.workspace:protocol), it also works. BUT! If local packages also have dependencies (local or from NPM), they will not be installed. I.e. package@local/backenddepends on@local/client, which depends onaxios.axiosis not installing, build failed.@urbanisierung i’m just appending an ellipsis i.e.
pnpm--filter package-a... i. This installspackage-adirect and indirect dependencies and root dependencies also.Also i feel like my issue is unrelated to this thread, because i don’t care about deduplication. I just set dedupe-peer-dependents to false in
pnpm config.yeah it’s still a problem
We probably need a notice on doc site to indicate that
install --filteris not working as expected with default config, that people need to implicitly setdedupe-peer-dependentstofalseto have that work.This is probably happening because this setting is true by default: https://pnpm.io/npmrc#dedupe-peer-dependents
There is a special command for preparing a package for docker: pnpm deploy.
This is not working when
node-linker=hoistedis set.I’m using version
9.4.0.I’m running the following command.
You can verify it in the following project.
https://gitlab.com/bitspur/multiplatform.one/multiplatform.one
Here is my
.npmrcfile.Try v9.4.0
I need to prune the dependencies from from packages that are not related to my current build to keep my docker image small. Right now I have to either delete the folders as @verekia suggested or remove the workspace from the
pnpm-workspaces.yaml. Either way, it completely recalculates which means I do not benefit from the lockfile.Quite the dilemma.
Thanks for that - it does work then, but yeah due to aforementioned issues from other commenters it doesn’t help in CI. Eagerly awaiting this to be resolved, as installs are using up a lot of CI time and therefore costing my company real dollars.
i’m finding on pnpm 8.7.0
pnpm i --filter=xxx --dedupe-peer-dependents=falsedoesn’t work with this error:Was this flag removed?
Thanks @nnhjs I’ll wait for this issue to be fixed. I have options to deal we that so it’s ok from my side.
I delete pnpm-lock file before building this specific app so i can then cp all {root}/node_modules to the app bundle (issue #6259)
It seems like
pnpm i --filter=xxx --dedupe-peer-dependents=falsefixes the issue indeed. Would be nice to maybe mention in the docs that this (default) setting “breaks” (depending on how you look at it 😛) some expected filters.Do we have any updates on this issue? 🤔 I still encountered it in my project, I can’t independently run
pnpm installon one package in a mono repo.I’m experiencing this bug too. I noticed when I tried to install only root workspace dependencies and it begun installing all dependencies. I also tried clearing node_modules, pnpm store, etc.