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-dependents
not set (thustrue
= default value of v8.0.0) - problem not present in 8.0.0 with
dedupe-peer-dependents
set 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 -v
prints: v16.19.0- Windows, macOS, or Linux?: Ubuntu 22.04.1 LTS
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 41
- Comments: 23 (3 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 8 months 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=false
would work as same effect.I’ve also noticed that setting
node-linker=hoisted
also installs all dependencies even whendedupe-peer-dependents
is set tofalse
.@urbanisierung i’m just appending an ellipsis i.e.
pnpm--filter package-a... i
. This installspackage-a
direct 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
.UPD: missed that
--filter
allows you to select dependencies also. Using-F project...
solves my problem.pnpm -F <project> --config.dedupe-peer-dependents=false i
works 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/backend
depends on@local/client
, which depends onaxios
.axios
is not installing, build failed.We probably need a notice on doc site to indicate that
install --filter
is not working as expected with default config, that people need to implicitly setdedupe-peer-dependents
tofalse
to have that work.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=false
doesn’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)
yeah it’s still a problem
This is probably happening because this setting is true by default: https://pnpm.io/npmrc#dedupe-peer-dependents