JGAntunes / bun-repro-dedup-issue

Reproduction case for bun's dependency deduplication issue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The issue

tl;dr when there's an empty node_modules directory in a project bun install does not correctly perform de deduplication of packages and we end up with missing packages for a project where different versions of the same package are required for a given set of dependencies.

To reproduce

Without a node_modules directory in the project:

# making sure we're working from a clean starting point
$ rm -rf node_modules

$ bun pm cache rm
Cache directory deleted:
  /Users/jgantunes/.bun/install/cache

$ bun install
bun install v1.0.6 (969da088)
 + eslint-plugin-prettier@5.0.1
 + release-it@16.2.1
 + rollup-plugin-visualizer@5.9.2

 466 packages installed [1434.00ms]

$ npm ls open
bun-repro-dedup-issue@1.0.0 /Users/jgantunes/workspace/netlify/vic-ai-tests/bun-repro-dedup-issue
├─┬ eslint-plugin-prettier@5.0.1
│ └─┬ synckit@0.8.5
│   └─┬ @pkgr/utils@2.4.2
│     └── open@9.1.0 deduped
├─┬ release-it@16.2.1
│ └── open@9.1.0
└─┬ rollup-plugin-visualizer@5.9.2
  └── open@8.4.2

$ find node_modules -name open
node_modules/open
node_modules/rollup-plugin-visualizer/node_modules/open

$ cat node_modules/open/package.json | jq .version
"9.1.0"

$ cat node_modules/rollup-plugin-visualizer/node_modules/open/package.json | jq .version
"8.4.2"

With a node_modules directory in the project:

# making sure we're working from a clean starting point
$ rm -rf node_modules

$ bun pm cache rm
Cache directory deleted:
  /Users/jgantunes/.bun/install/cache

$ mkdir node_modules

$ bun install
bun install v1.0.6 (969da088)
 + eslint-plugin-prettier@5.0.1
 + release-it@16.2.1
 + rollup-plugin-visualizer@5.9.2

 421 packages installed [1189.00ms]

$ npm ls open
npm ERR! code ELSPROBLEMS
npm ERR! invalid: open@9.1.0 /Users/jgantunes/workspace/netlify/vic-ai-tests/bun-repro-dedup-issue/node_modules/open
bun-repro-dedup-issue@1.0.0 /Users/jgantunes/workspace/netlify/vic-ai-tests/bun-repro-dedup-issue
├─┬ eslint-plugin-prettier@5.0.1
│ └─┬ synckit@0.8.5
│   └─┬ @pkgr/utils@2.4.2
│     └── open@9.1.0 deduped invalid: "^8.4.0" from node_modules/rollup-plugin-visualizer
├─┬ release-it@16.2.1
│ └── open@9.1.0 invalid: "^8.4.0" from node_modules/rollup-plugin-visualizer
└─┬ rollup-plugin-visualizer@5.9.2
  └── open@9.1.0 deduped invalid: "^8.4.0" from node_modules/rollup-plugin-visualizer


npm ERR! A complete log of this run can be found in: /Users/jgantunes/.npm/_logs/2023-10-12T11_37_50_768Z-debug-0.log

$ find node_modules -name open
node_modules/open

$ cat node_modules/open/package.json | jq .version
"9.1.0"

About

Reproduction case for bun's dependency deduplication issue