oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.52k stars 2.71k forks source link

Error Loading ES Modules in CommonJS Environment with bun create Command #9961

Open siguici opened 6 months ago

siguici commented 6 months ago

What version of Bun is running?

1.1.1+ca1dbb4eb

What platform is your computer?

Linux 6.5.0-17-generic x86_64 x86_64

What steps can reproduce the bug?

Create a New Project with bun create:

Use the bun create command to generate a new Astro project. Run the following command in your terminal:

bun create astro@latest

If the bug is reproducible, you should encounter an error related to loading ES (ECMAScript) modules within a CommonJS environment. The error message may look similar to the following:

/tmp/bunx-1000-create-astro@latest/node_modules/string-width/index.js:3
const isFullwidthCodePoint = require('is-fullwidth-code-point');
                             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/bunx-1000-create-astro@latest/node_modules/is-fullwidth-code-point/index.js from /tmp/bunx-1000-create-astro@latest/node_modules/string-width/index.js not supported.
Instead change the require of /tmp/bunx-1000-create-astro@latest/node_modules/is-fullwidth-code-point/index.js in /tmp/bunx-1000-create-astro@latest/node_modules/string-width/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/tmp/bunx-1000-create-astro@latest/node_modules/string-width/index.js:3:30) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v20.12.0

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

VigilioYonatan commented 4 months ago

any update?