oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager ā€“ all in one
https://bun.sh
Other
72.99k stars 2.66k forks source link

Bun install incorrect dependency for `c8` #12004

Open coderaiser opened 2 months ago

coderaiser commented 2 months ago

What version of Bun is running?

1.1.14

What platform is your computer?

mac os

What steps can reproduce the bug?

coderaiser@localcmd:~/putout$ git clone https://github.com/coderaiser/putout && bun i --no-save
coderaiser@localcmd:~/putout$ node_modules/.bin/c8 npm test
/Users/coderaiser/putout/node_modules/c8/node_modules/cliui/build/index.cjs:292
const stripAnsi = require('strip-ansi');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/coderaiser/putout/node_modules/strip-ansi/index.js from /Users/coderaiser/putout/node_modules/c8/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /Users/coderaiser/putout/node_modules/c8/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/coderaiser/putout/node_modules/c8/node_modules/cliui/build/index.cjs:292:19) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.3.0

What is the expected behavior?

Expected c8 installed correctly

What do you see instead?

Incorrect dependency strip-ansi installed for c8

Additional information

cliui requires strip-ansi@6.0.1, but it is not installed at all, only version strip-ansi@7 used, which is required by šŸŠPutout, it is ESM and everything is failed

dylan-conway commented 2 months ago

Having trouble reproducing this bug. Does it happen consistently?

We recently started hoisting aliased packages (@isaacs/cliui uses three). Does this error still occur if you delete node_modules/c8/node_modules/ and reinstall?

github-actions[bot] commented 2 months ago

Hello @coderaiser. Please provide a minimal reproduction using a GitHub repository, Replit, or CodeSandbox. Issues marked with needs repro will be closed if they have no activity within 3 days.

coderaiser commented 2 months ago

Yes, after removing node_modules it works good, here is steps to reproduce inside putout repository:

npm i lerna@6 -g
lerna bootstrap
bun i
dylan-conway commented 2 months ago

Yes, after removing node_modules it works good, here is steps to reproduce inside putout repository:

npm i lerna@6 -g
lerna bootstrap
bun i

Thanks, I can repro this. This is happening because bun is not resetting node_modules after installing with another package manager