Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gokanlam opened this issue Nov 19, 2023 · 13 comments · Fixed by #5281, #5290 or #5292
Closed

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

gokanlam opened this issue Nov 19, 2023 · 13 comments · Fixed by #5281, #5290 or #5292
Assignees
Labels
bug Something isn't working

Comments

@gokanlam
Copy link

gokanlam commented Nov 19, 2023

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 gokanlam added the bug Something isn't working label Nov 19, 2023
@romainds-tech
Copy link

romainds-tech commented Nov 19, 2023

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

@3MenWalking
Copy link

3MenWalking commented Nov 19, 2023

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?

@medrishya
Copy link

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

@aliemir aliemir linked a pull request Nov 20, 2023 that will close this issue
6 tasks
@omeraplak omeraplak assigned BatuhanW and aliemir and unassigned BatuhanW Nov 20, 2023
@aliemir
Copy link
Member

aliemir commented Nov 20, 2023

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

@ernestasgobionis
Copy link

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
Copy link

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

@BatuhanW
Copy link
Member

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
Copy link

ernestasgobionis commented Nov 20, 2023

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]

@romainds-tech
Copy link

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
Copy link
Member

BatuhanW commented Nov 20, 2023

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

omnidan/node-emoji#154

omnidan/node-emoji#153

@3MenWalking
Copy link

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

@JoshuaKGoldberg
Copy link

JoshuaKGoldberg commented Nov 20, 2023

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.

Cheers! 👋

@BatuhanW
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
8 participants