Matthew Winfield
Matthew Winfield

Reputation: 967

Rush Monorepo - Shared dependency is duplicated in node_modules

I'm using Rush to manage a monorepo, in which multiple packages depend on react-redux. They both specify the exact same version in their package.json file.

Project A: Package dependency screenshot

Project B: Package dependency screenshot

Project B also depends on Project A.

I would expect that since they both use the exact same package version, that they would both link to the same folder in common/temp/node_modules/.pnpm. But instead they are linked to two different folders, with some random string (maybe a hash?) appended:

Screenshot of node_modules with duplicate react-redux package

This breaks things since Package B creates the redux <Provider> but when it calls functions from Package A, they look for the context created by one of the versions of react-redux but Package B initialised the provider with the other version.

Why is Rush making two copies of this same version? How can I prevent it from doing this and make both packages point to the same copy?

Upvotes: 2

Views: 944

Answers (1)

Matthew Winfield
Matthew Winfield

Reputation: 967

I fixed this issue - Disable useWorkspaces in rush.json

Upvotes: 3

Related Questions