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

fix: use ESM for cli #3642

Closed
1 of 4 tasks
JounQin opened this issue Aug 15, 2023 · 12 comments · Fixed by #3850
Closed
1 of 4 tasks

fix: use ESM for cli #3642

JounQin opened this issue Aug 15, 2023 · 12 comments · Fixed by #3850
Labels

Comments

@JounQin
Copy link
Contributor

JounQin commented Aug 15, 2023

Expected Behavior

wrap-ansi required by cliui by yargs is ESM only now

Current Behavior

$ /Users/JounQin/Workspaces/Alauda/ui/node_modules/.bin/commitlint -e
/Users/JounQin/Workspaces/Alauda/ui/node_modules/cliui/build/index.cjs:293
const wrap = require('wrap-ansi');
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/JounQin/Workspaces/Alauda/ui/node_modules/wrap-ansi/index.js from /Users/JounQin/Workspaces/Alauda/ui/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /Users/JounQin/Workspaces/Alauda/ui/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/JounQin/Workspaces/Alauda/ui/node_modules/cliui/build/index.cjs:293:14)
    at Object.<anonymous> (/Users/JounQin/Workspaces/Alauda/ui/node_modules/yargs/build/index.cjs:1:60678)
    at Object.<anonymous> (/Users/JounQin/Workspaces/Alauda/ui/node_modules/yargs/index.cjs:5:30)
    at Object.<anonymous> (/Users/JounQin/Workspaces/Alauda/ui/node_modules/@commitlint/cli/lib/cli.js:20:33)
    at Object.<anonymous> (/Users/JounQin/Workspaces/Alauda/ui/node_modules/@commitlint/cli/cli.js:2:1) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.1

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Use ESM for cli

related yargs/cliui#139

Steps to Reproduce

N/A

Context

No response

commitlint --version

@commitlint/[email protected]

git --version

2.41.0

node --version

v18.17.1

@escapedcat
Copy link
Member

How to repoduce this? You got a repo?

@JounQin
Copy link
Contributor Author

JounQin commented Aug 15, 2023

It seems a package manager issue which resolves wrap-ansi@8 in node_modules/wrap-ansi but it should be node_modules/cliui/node_modules/wrap-ansi actually. Close for now.

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
@lstoeferle
Copy link

Hey @JounQin,
I'm getting the same error in one of my ESM projects using yarn. Do you have any idea how to fix this?

@sankarge
Copy link

The following did the trick.

rm -rf node_modules
rm yarn.lock
yarn install

@JounQin
Copy link
Contributor Author

JounQin commented Jan 11, 2024

Hey @JounQin, I'm getting the same error in one of my ESM projects using yarn. Do you have any idea how to fix this?

Sorry, I'm late. I was using patch-package to do the trick.

@escapedcat
Copy link
Member

Could this be solved by commitlint with a resolution?

@JounQin
Copy link
Contributor Author

JounQin commented Jan 11, 2024

Could this be solved by commitlint with a resolution?

Maybe as I said, migrate cli to ESM.

@escapedcat
Copy link
Member

Maybe as I said, migrate cli to ESM.

Currently no time or motivation. Happy for any help.

@escapedcat
Copy link
Member

Could this be solved by commitlint with a resolution?

Happy for a PR here

@JounQin
Copy link
Contributor Author

JounQin commented Jan 11, 2024

OK, I'll raise a PR then.

@JounQin JounQin reopened this Jan 11, 2024
@JounQin JounQin mentioned this issue Jan 12, 2024
10 tasks
@JounQin
Copy link
Contributor Author

JounQin commented Jan 12, 2024

@escapedcat Please help to review #3850, I've fixed almost all test cases except a few ones which seems to be related to Terminal colors and locale.

@escapedcat
Copy link
Member

Also linking #3251 here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

4 participants