Reputation: 105
I am using pnpm workspace to manage my projects. The folder structure looks like this.
└── my-project/
├── apps/
│ └── myapp/
│ ├── package1
│ ├── package2
│ └── [email protected]
├── packages/
│ ├── package1/
│ │ └── [email protected]
│ └── package2/
│ ├── package1
│ └── [email protected]
├── package.json
└── pnpm-workspace.yaml
And all of them are included in package.json dependencies field.
When i checked /node_modules/.pnpm/ folder, i saw there are 2 folders generated for styled-components. I thought it should only have one instance but apparently it doesnot. Does someone know why pnpm behaves like this? Thank you.
PS: My env is:
node: 18.15.0
pnpm: 7.29.2
.npmrc:
public-hoist-pattern[]=@types*
dedupe-peer-dependents=true
esolve-peers-from-workspace-root=true
Upvotes: 0
Views: 471
Reputation: 7666
It can happen with package that depend on peer dependencies. If style-components is in the dependencies of several projects or dependencies of the project, then it may happen that in one place it is resolved with one set of peer dependencies while in another place it is resolved with a different set of peer dependencies.
Usually setting auto-install-peers=true
(which is true by default in pnpm v8) and dedupe-peer-dependents=true
reduce the number of such duplicates.
You can also true to force the same version of the peer dependency (if it isn't resolved from a direct dependency) using overrides.
Also, I see a typo in your settings. The last setting is missing "r" from the beginning.
Upvotes: 0