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

ERR_REQUIRE_ESM #31

Closed
SeverinAlexB opened this issue Feb 14, 2023 · 0 comments · Fixed by #33
Closed

ERR_REQUIRE_ESM #31

SeverinAlexB opened this issue Feb 14, 2023 · 0 comments · Fixed by #33

Comments

@SeverinAlexB
Copy link

Looks like the import of ansi-regex in @clack/prompts/dist/index.cjs causes my CommonJs project to crash.

/Users/severinbuhler/git/synonym/blocktank-instant/node_modules/@clack/prompts/dist/index.cjs:1
"use strict";const core=require("@clack/core"),color=require("picocolors"),sisteransi=require("sisteransi"),ansiRegex=require("ansi-regex"),symbol=t=>{switch(t){case"initial":case"active":return color.cyan("\u25CF");case"cancel":return color.red("\u25A0");case"error":return color.yellow("\u25B2");case"submit":return color.green("\u25CB")}},barStart="\u250C",bar="\u2502",barEnd="\u2514",text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,render(){const i=`${color.gray(bar)}
                                                                                                                      ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/severinbuhler/git/synonym/blocktank-instant/node_modules/@clack/prompts/node_modules/ansi-regex/index.js from /Users/severinbuhler/git/synonym/blocktank-instant/node_modules/@clack/prompts/dist/index.cjs not supported.
Instead change the require of index.js in /Users/severinbuhler/git/synonym/blocktank-instant/node_modules/@clack/prompts/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/severinbuhler/git/synonym/blocktank-instant/node_modules/@clack/prompts/dist/index.cjs:1:119)
    at Object.<anonymous> (/Users/severinbuhler/git/synonym/blocktank-instant/dist/3_cli/index.js:26:29) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.12.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant