Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Consider the following scenario (also available at https://github.com/gplopes/npm-dedupe-peer-deps for repro).
// main-app
"package-a": "file:../package-a",
"package-b": "file:../package-b",
"graphql": "15.0.0"
// package=a
"graphql": "16.5.0",
"@graphql-tools/schema": "8.3.8", // peerDependency: graphql "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
"@graphql-tools/stitch": "8.6.12" // peerDependency: graphql "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
// package-b
"graphql": "15.0.0"
The npm install will produce following node_modules structure:
// node_modules (root)
│ "graphql": "15.0.0" // deduped
│ "@graphql-tools/schema": "8.3.8" // issue lays here where this package now references the root graphql which is a different version than the one install in package-a
│ "@graphql-tools/stitch": "8.6.12"
│
└───project-a/node_modules
│ └───"graphql": "16.5.0" // not deduped
│
└───project-b/node_modules
└───"graphql": "15.0.0" // deduped (using root package)
@graphql-tools/schema uses the wrong graphql version from the root project (main-app).
The version of graphql for @graphql-tools/schema should be decided by the actual consumer of @graphql-tools/schema, which in this case is project-a, not main-app.
Expected Behavior
npm install should produce following node_modules stucture:
// node_modules (root)
│ "graphql": "15.0.0" // deduped
│
└───project-a/node_modules
│ └───"graphql": "16.5.0"
│ └───"@graphql-tools/schema": "8.3.8" // should not be deduped as the project depends on graphql: 16.5.0
│ └───"@graphql-tools/stitch": "8.6.12" // should not be deduped as the project depends on graphql: 16.5.0
│
└───project-b/node_modules
└───"graphql": "15.0.0" // deduped (using root package)
Deduplication should consider the version of graphql installed in project-a to be the required version for its dependancies defining graphql as peer dependancy, like @graphql-tools/schema in this scenario.
Alternatively, sub dependancies with peer dependancies defined should not be deduped at all for version safety.
Steps To Reproduce
- Clone https://github.com/gplopes/npm-dedupe-peer-deps.
- Run
npm i.
- Check the
node_modules folder where @graphql-tools/schema and @graphql-tools/stitch are deduped to the root node_modules.
Environment
- npm: 8.15.0
- Node.js: 16.15.1
- OS Name: MacOS Monterey
- System Model Name: 12.4
- npm config:
; "user" config from /Users/georgymarchuk/.npmrc
@pipedrive:registry = "https://npm-registry-proxy.pipedrive.tools"
//npm-registry-proxy.pipedrive.tools/:_authToken = (protected)
//npm-registry-proxy.pipedrive.tools/:always-auth = true
//registry.npmjs.org/:_authToken = (protected)
; node bin location = /Users/georgymarchuk/.nvm/versions/node/v16.15.1/bin/node
; node version = v16.15.1
; npm local prefix = /Users/georgymarchuk/git/npm-dedupe-peer-deps
; npm version = 8.15.0
; cwd = /Users/georgymarchuk/git/npm-dedupe-peer-deps
; HOME = /Users/georgymarchuk
; Run `npm config ls -l` to show all defaults.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Consider the following scenario (also available at https://github.com/gplopes/npm-dedupe-peer-deps for repro).
The
npm installwill produce following node_modules structure:@graphql-tools/schemauses the wronggraphqlversion from the root project (main-app).The version of
graphqlfor@graphql-tools/schemashould be decided by the actual consumer of@graphql-tools/schema, which in this case isproject-a, notmain-app.Expected Behavior
npm installshould produce following node_modules stucture:Deduplication should consider the version of
graphqlinstalled inproject-ato be the required version for its dependancies defininggraphqlas peer dependancy, like@graphql-tools/schemain this scenario.Alternatively, sub dependancies with peer dependancies defined should not be deduped at all for version safety.
Steps To Reproduce
npm i.node_modulesfolder where@graphql-tools/schemaand@graphql-tools/stitchare deduped to the root node_modules.Environment