refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
27.88k stars 2.16k forks source link

[BUG] Error [ERR_REQUIRE_ESM]: require() of ES Module #5279

Closed gokanlam closed 10 months ago

gokanlam commented 10 months ago

Describe the bug

After creating a new application with the npm create refine-app@latest testapp command, the application does not start with the nmp run dev command and the following error occurs:

> testapp@0.1.0 refine
> refine

/home/user/testapp/node_modules/node-emoji/lib/index.cjs:47
var import_is2 = __toESM(require("@sindresorhus/is"), 1);
                         ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/testapp/node_modules/@sindresorhus/is/dist/index.js from /home/user/testapp/node_modules/node-emoji/lib/index.cjs not supported.
Instead change the require of index.js in /home/user/testapp/node_modules/node-emoji/lib/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/user/testapp/node_modules/node-emoji/lib/index.cjs:47:26)
    at Object.<anonymous> (/home/user/testapp/node_modules/marked-terminal/index.cjs:10:13)
    at Object.<anonymous> (/home/user/testapp/node_modules/@refinedev/cli/dist/cli.js:25:1400) {
  code: 'ERR_REQUIRE_ESM'
}

Steps To Reproduce

  1. npm create refine-app@latest testapp
    ✔ Choose a project template · refine-vite
    ✔ What would you like to name your project?: · testapp
    ✔ Choose your backend service to connect: · data-provider-strapi-v4
    ✔ Do you want to use a UI Framework?: · antd
    ✔ Do you want to add example pages?: · no
    ✔ Do you need i18n (Internationalization) support?: · no
  2. cd testapp
  3. npm run dev

Expected behavior

Run normally.

Screenshot

No response

Desktop

No response

Mobile

No response

Additional Context

OS: ubuntu 22.04 LTS Node: v20.9.0 NPM: v10.1.0 create-refine-app: v1.12.1

romainds-tech commented 10 months ago

I have the same error, impossible to run dev a new project

3MenWalking commented 10 months ago

Same exact issue here with a totally fresh install of all the toolchain on a Mac(NVM/NPM/Node, etc ). Impossible to continue.

I also tried to use a older version of refin-eapp and still no go: npm create refine-app@1.11.0 -- -o refine-mui tutorial2

Can you provide your packge-lock.json so we can move on?

medrishya commented 10 months ago

I too have got the same issue, impossible to run a new latest refine project.

aliemir commented 10 months ago

Sorry for the issue! 🙏 We've just opened a PR to fix it. It will be released as soon as workflows are complete! 🚀

ernestasgobionis commented 10 months ago

Just created a new project which includes the latest update to node-emoji: 2.1.0, and I'm getting the exact same error

romainds-tech commented 10 months ago

I'm getting the exact same error too with a new project I use this command : npm create refine-app@latest

BatuhanW commented 10 months ago

Hello folks, using the command npm create refine-app@latest testapp, couldn't reproduce the problem, as you can see in the screenshot, it works as expected. I can see the welcome page as expected, could you double-check your configuration or provide a minimal reproducible example if possible?

Screenshot 2023-11-20 at 19 09 32

Screenshot 2023-11-20 at 19 10 58

ernestasgobionis commented 10 months ago

Here you go:repo

image

Also note I found that when I run npm ls node-emoji, I get this output:

refine-repro@0.1.0 /Users/ex/Desktop/refine-admin/refine-repro
└─┬ @refinedev/cli@2.16.17
  ├─┬ marked-terminal@6.1.0
  │ └── node-emoji@2.1.1
  └── node-emoji@2.1.0

Looks like 2.1.1 is coming from marked-terminal@6.1.0

romainds-tech commented 10 months ago

Hi @BatuhanW, I use this configuration

CleanShot 2023-11-20 at 17 36 17@2x

then when I use pnpm dev I got this error

CleanShot 2023-11-20 at 17 37 11@2x

BatuhanW commented 10 months ago

Hello folks, it seems we still have this issue with yarn and pnpm package managers. As a temporary workaround, you can use npm to install dependencies.

Also we've noticed that a new version is released 15 minutes ago, we'll upgrade to use it.

https://www.npmjs.com/package/node-emoji/v/2.1.2

https://github.com/omnidan/node-emoji/pull/154

https://github.com/omnidan/node-emoji/issues/153

3MenWalking commented 10 months ago

Can confirm using npm with the latest now works. Thanks!

JoshuaKGoldberg commented 10 months ago

Hiyall - this was me, sorry about that. I'd neglected to fully test a tooling upgrade for node-emoji that bumped dependencies, enabled auto-updates via Renovate for others, and didn't add an end-to-end test that CommonJS consumers wouldn't be broken.

node-emoji@2.1.3 is published now and should be working for CommonJS consumers again. Please do let us know in https://github.com/omnidan/node-emoji if anything else gets / is broken!

Also, copying here in case it's useful for this or similar situations: a workaround that should work across package managers in the case of a dependency breaking, including a deep dependency-of-a-dependency, is using an overrides/resolutions style pin.

Cheers! 👋

BatuhanW commented 10 months ago

Thanks a lot @JoshuaKGoldberg, tested with pnpm, and I can confirm, it works as expected!