refine icon indicating copy to clipboard operation
refine copied to clipboard

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

Open gokanlam opened this issue 3 years ago • 13 comments

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:

> [email protected] 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
  1. cd testapp
  2. 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

gokanlam avatar Nov 19 '23 16:11 gokanlam

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

romainds-tech avatar Nov 19 '23 18:11 romainds-tech

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 [email protected] -- -o refine-mui tutorial2

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

3MenWalking avatar Nov 19 '23 19:11 3MenWalking

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

medrishya avatar Nov 20 '23 05:11 medrishya

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

aliemir avatar Nov 20 '23 06:11 aliemir

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

ernestasg152 avatar Nov 20 '23 15:11 ernestasg152

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

romainds-tech avatar Nov 20 '23 16:11 romainds-tech

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

BatuhanW avatar Nov 20 '23 16:11 BatuhanW

Here you go:repo

image

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

[email protected] /Users/ex/Desktop/refine-admin/refine-repro
└─┬ @refinedev/[email protected]
  ├─┬ [email protected]
  │ └── [email protected]
  └── [email protected]

Looks like 2.1.1 is coming from [email protected]

ernestasg152 avatar Nov 20 '23 16:11 ernestasg152

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

romainds-tech avatar Nov 20 '23 16:11 romainds-tech

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

BatuhanW avatar Nov 20 '23 16:11 BatuhanW

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

3MenWalking avatar Nov 20 '23 16:11 3MenWalking

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.

[email protected] 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.

  • npm: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides
  • pnpm: https://pnpm.io/package_json#pnpmoverrides (secondary: https://pnpm.io/package_json#resolutions)
  • Yarn classic: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/
  • Yarn berry/2+: https://yarnpkg.com/cli/set/resolution

Cheers! 👋

JoshuaKGoldberg avatar Nov 20 '23 22:11 JoshuaKGoldberg

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

BatuhanW avatar Nov 20 '23 23:11 BatuhanW