{"id":17348837,"url":"https://github.com/gplopes/npm-dedupe-peer-deps","last_synced_at":"2026-01-06T08:11:46.638Z","repository":{"id":47296986,"uuid":"515998559","full_name":"gplopes/npm-dedupe-peer-deps","owner":"gplopes","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-21T11:49:27.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T16:22:08.431Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gplopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-20T13:43:25.000Z","updated_at":"2022-07-20T14:18:17.000Z","dependencies_parsed_at":"2022-08-22T20:01:11.837Z","dependency_job_id":null,"html_url":"https://github.com/gplopes/npm-dedupe-peer-deps","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gplopes%2Fnpm-dedupe-peer-deps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gplopes%2Fnpm-dedupe-peer-deps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gplopes%2Fnpm-dedupe-peer-deps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gplopes%2Fnpm-dedupe-peer-deps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gplopes","download_url":"https://codeload.github.com/gplopes/npm-dedupe-peer-deps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841644,"owners_count":20681183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T16:53:41.556Z","updated_at":"2026-01-06T08:11:41.573Z","avatar_url":"https://github.com/gplopes.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"npm issue: peer dependencies dedupe\n\ninstall packages at the root directly  ``npm install``\n\nWe've encountered a wrong behavior with npm dedupe functionality with peer dependencies. \nIn this demo, there are 3 modules and their dependencies tree looks like this:\n\n\n```js\n// main-app\n\"package-a\": \"file:../package-a\",\n\"package-b\": \"file:../package-b\",\n\"graphql\": \"15.0.0\"\n\n// package=a\n \"graphql\": \"16.5.0\",\n \"@graphql-tools/schema\": \"8.3.8\", // peerDependency: graphql \"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0\"\n \"@graphql-tools/stitch\": \"8.6.12\" // peerDependency: graphql \"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0\"\n\n// package-b\n\"graphql\": \"15.0.0\"\n```\n\n**Expected behavior:**\n\n```js\n// node_modules (root)\n│  \"graphql\": \"15.0.0\" // deduped \n│\n└───project-a/node_modules\n│   └───\"graphql\": \"16.5.0\"\n│   └───\"@graphql-tools/schema\": \"8.3.8\" // should not be deduped as the project depends on graphql: 16.5.0\n│   └───\"@graphql-tools/stitch\": \"8.6.12\" // should not be deduped as the project depends on graphql: 16.5.0\n│   \n└───project-b/node_modules\n    └───\"graphql\": \"15.0.0\" // deduped (using root package)\n```\n\n**Current behavior:**\n\n`@graphql-tools/schema` uses the wrong `graphql` version from the root project (`main-app`).\nThe 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`. \n\nDeduplication is not taking this into consideration, and should consider the version of `graphql` installed in `project-a` to be the required version for another dependancies defining `graphql` as peer dependancy, like `@graphql-tools/schema` in this scenario. \n\nAlternativelly, packages with peer dependancies should not be deduped at all for version safety. \n\n```js\n// node_modules (root)\n│  \"graphql\": \"15.0.0\" // deduped \n│  \"@graphql-tools/schema\": \"8.3.8\"  // issue lays here where this package now references the root graphql which is a different version\n│  \"@graphql-tools/stitch\": \"8.6.12\"\n│\n└───project-a/node_modules\n│   └───\"graphql\": \"16.5.0\" // not deduped\n│   \n└───project-b/node_modules\n    └───\"graphql\": \"15.0.0\" // deduped (using root package)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgplopes%2Fnpm-dedupe-peer-deps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgplopes%2Fnpm-dedupe-peer-deps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgplopes%2Fnpm-dedupe-peer-deps/lists"}