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 report] ERROR: require() of ES Module | configure rename to commitlint.config.cjs #159

Closed
2 tasks done
xiangshu233 opened this issue Feb 23, 2024 · 12 comments
Closed
2 tasks done
Assignees
Labels
not bug | wontfix This is't cz-git bug

Comments

@xiangshu233
Copy link

xiangshu233 commented Feb 23, 2024

โœ… Checklist

  • I am using the latest version
  • I have searched FAQ

๐Ÿ“„ System Info

๐Ÿ˜€๐Ÿ’ฌ ~ cz
[email protected], [email protected]

require() of ES Module F:\Project\vue3-vant4-mobile\commitlint.config.js from F:\Project\vue3-vant4-mobile\node_modules\.pnpm\c[email protected]\node_modules\cz-git\lib\index.js not supported.
Instead change the require of commitlint.config.js in F:\Project\vue3-vant4-mobile\node_modules\.pnpm\c[email protected]\node_modules\cz-git\lib\index.js to a dynamic import() which is available in all CommonJS modules.

๐Ÿ”Ž Description

Concise Description

commitlint.config.js ๆ”นไธบ ES ๆจกๅ—ๅŽ๏ผŒcz ๅ‘ฝไปคๆŠฅ้”™ๆ็คบ cz-git ไธๆ”ฏๆŒ ES

Expected behavior

commitlint.config.js ๆ”นไธบ ES ๆจกๅ—ๅŽ cz ๅฏไปฅๆญฃๅธธๆ‹‰่ตท cz-git

Steps to reproduce

commitlint.config.js ๆ”นไธบ ES Module๏ผŒๆ‰ง่กŒ cz ๆŠฅ้”™

Screenshots or Screen Recording(if possible)

image

๐Ÿ”— Reproduction link / repo:

No response

@xiangshu233 xiangshu233 added the bug Something isn't working label Feb 23, 2024
@Zhengqbbb
Copy link
Owner

CleanShot 2024-02-23 at 21 44 19@2x

@Zhengqbbb Zhengqbbb added not bug | wontfix This is't cz-git bug and removed bug Something isn't working labels Feb 23, 2024
@Zhengqbbb Zhengqbbb changed the title [Bug report] commitlint.config.js ๆ”นๅฑ‚ ES ๆจกๅ—ๅŽ๏ผŒcz ๅ‘ฝไปคๆŠฅ้”™ๆ็คบ cz-git ไธๆ”ฏๆŒ ES [Bug report] ERROR: require() of ES Module | configure rename to commitlint.config.cjs Feb 23, 2024
@xiangshu233
Copy link
Author

ไธๅฅฝๆ„ๆ€ๅŽ้ขๅฟ˜่ฎฐๆ่ฟฐไบ†๏ผŒๆˆ‘็Žฐๅœจๅฐฑๆ˜ฏๆ”นๆˆไบ† commitlint.config.cjs๏ผŒ็ปง็ปญไฝฟ็”จ CommonJS ่ฏญๆณ•๏ผŒๆขๆˆ Vite5๏ผŒๆฏๆฌกๅฏๅŠจไผšๆœ‰่ญฆๅ‘Šๅผนๅ‡บ๏ผŒ่™ฝ็„ถๅŠŸ่ƒฝๆ˜ฏๆญฃๅธธ็š„๏ผŒไฝ†ๆ˜ฏๆœ‰็‚นๅผบ่ฟซ็—‡๐Ÿ˜‚
image

@Zhengqbbb
Copy link
Owner

image


่›ค๏ผ๏ผŸ๏ผŸ๏ผŒๆ˜ฏไปปไฝ•ๅ‘ฝไปคๅฏๅŠจ่ฟ˜ๆ˜ฏ่ฏด็”จ vite ๅ‘ฝไปคไผšๅ‘ๅ‡บ

@xiangshu233
Copy link
Author

ไฝฟ็”จ vite5 ็‰ˆๆœฌ็š„ๅ‘ฝไปคไผšๆ็คบ่ฟ™ไธช่ญฆๅ‘Š
https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

Vite Node API ็š„ CJS ็‰ˆๆœฌๅทฒๅผƒ็”จ๏ผŒๅนถๅฐ†ๅœจ Vite 6 ไธญๅˆ ้™คใ€‚ๆœ‰ๅ…ณๆ›ดๅคšไธŠไธ‹ๆ–‡๏ผŒ่ฏทๅ‚้˜… GitHub ่ฎจ่ฎบใ€‚ๆ‚จๅบ”่ฏฅๆ›ดๆ–ฐๆ‚จ็š„ๆ–‡ไปถๆˆ–ๆก†ๆžถไปฅ> ๅฏผๅ…ฅ Vite ็š„ ESM ็‰ˆๆœฌใ€‚

@Zhengqbbb
Copy link
Owner

Zhengqbbb commented Feb 24, 2024

ไฝฟ็”จ vite5 ็‰ˆๆœฌ็š„ๅ‘ฝไปคไผšๆ็คบ่ฟ™ไธช่ญฆๅ‘Š https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

Vite Node API ็š„ CJS ็‰ˆๆœฌๅทฒๅผƒ็”จ๏ผŒๅนถๅฐ†ๅœจ Vite 6 ไธญๅˆ ้™คใ€‚ๆœ‰ๅ…ณๆ›ดๅคšไธŠไธ‹ๆ–‡๏ผŒ่ฏทๅ‚้˜… GitHub ่ฎจ่ฎบใ€‚ๆ‚จๅบ”่ฏฅๆ›ดๆ–ฐๆ‚จ็š„ๆ–‡ไปถๆˆ–ๆก†ๆžถไปฅ> ๅฏผๅ…ฅ Vite ็š„ ESM ็‰ˆๆœฌใ€‚

ๆ„Ÿ่ง‰ไฝ ๅฏไปฅไฝฟ็”จ่ฟ™ไธชๅ‘ฝไปค็œ‹็œ‹ๆ˜ฏไป€ไนˆๆ–‡ไปถๆˆ–่€…ๅ…ถไป–ไพ่ต–่ขซไพ่ต–ๅˆฐๅค„่ญฆๅ‘Šๅ‘ๅ‡บ

VITE_CJS_TRACE=true pnpm dev

ๅฆ‚ๆžœๆ˜ฏๅ› ไธบๆ น็›ฎๅฝ•ๅญ˜ๅœจ .cjs ๆ–‡ไปถๅฏผ่‡ด่ญฆๅ‘Šๅ‘ๅ‡บ้‚ฃๅฐฑๅคชไธๅบ”่ฏฅไบ†...

@xiangshu233
Copy link
Author

@Zhengqbbb ๆ„Ÿ่ฐขๅคงไฝฌ๏ผŒๅฐ่ฏ•ไบ†ไธ€ไธ‹่ฟ™ไธชๅ‘ฝไปคใ€‚ๅฏๅŠจๅŽๅŽŸๆฅ่ญฆๅ‘Š็›ดๆŽฅๆฒกๆœ‰ไบ†๐Ÿ˜‚๏ผŒๅฎšไฝไธๅˆฐ้—ฎ้ข˜๏ผŒ่€Œไธ”ๅฆ‚ๆžœ cz-git ็š„่ฏ ๅฟ…้กปๅœๆŽ‰้กน็›ฎๆ‰่ƒฝ่ฟ่กŒ cz ๅ‘ฝไปคๆ‹‰่ตท๏ผŒๆ‰€ไปฅ่ฟ™ไธชๅ‘ฝไปคๅœจ่ฟ™ไธชๆƒ…ๅ†ตไธ‹ไผผไนŽๆฒกๆœ‰ๆ„ไน‰

QQ2024224-20366.mp4

็œ‹ๆฅๆˆ‘ๅช่ƒฝๅ…ˆๅฟฝ็•ฅ่ฟ™ไธช่ญฆๅ‘Šไบ†

@Zhengqbbb
Copy link
Owner

็œ‹ๆฅๆˆ‘ๅช่ƒฝๅ…ˆๅฟฝ็•ฅ่ฟ™ไธช่ญฆๅ‘Šไบ†

ๅฆ‚ๆžœๅญ˜ๅœจ .cjs ๆ–‡ไปถๅฐฑ่ญฆๅ‘Šๆ˜ฏๅง...ไป–ไปฌไธๅบ”่ฏฅ่ฟ™ๆ ทๅš็š„ ๐Ÿ™ƒ ๅฏไปฅ่ฏ•่ฏ•ๅˆ ้™ค commitlint..config.cjs๏ผŒ็„ถๅŽๅฏๅŠจๅฎšไฝไธ€ไธ‹ๅฐฑ็Ÿฅ้“ๆ˜ฏไธๆ˜ฏ่ฟ™ไธช้—ฎ้ข˜

@xiangshu233
Copy link
Author

ไธ็Ÿฅ้“ๆ˜ฏไธๆ˜ฏ่ฟ™ๆ ทไฝฟ็”จๅ‘ฝไปค๏ผŒๆˆ‘ๅœจ stackoverflow ๆœ็š„๐Ÿ˜‚๏ผŒไนŸๆœ‰ๅ†™ๅœจ .env ้‡Œ็š„๏ผŒไฝ†ๆ˜ฏๆˆ‘ๅธ่ฝฝ .env ็š„ๅฟฝ็•ฅ่ญฆๅ‘ŠไผผไนŽไนŸไธ่ตทไฝœ็”จ

image

@Zhengqbbb
Copy link
Owner

Zhengqbbb commented Feb 24, 2024

ๆˆ‘็œ‹ไฝ ไฝฟ็”จไบ† set ๅ‘ฝไปค, ๆ˜ฏ Windows ็”จๆˆท

็กฎๅฎžๆฒกๆœ‰ๅƒ .zshrc .bashrc ้‚ฃๆ ทๅฎนๆ˜“่ฎพ็ฝฎ

ๅฏไปฅ็œ‹็œ‹่ฟ™ไธช๏ผš https://chenjuefei.com:444/167.html

@xiangshu233
Copy link
Author

ๅฅฝ็š„๏ผŒๆ„Ÿ่ฐขๅคงไฝฌ็š„ๅ›žๅค๏ผŒๆ‰“ๆ‰ฐไบ†๏ผŒๅ…ƒๅฎต่Š‚ๅฟซไน

@Zhengqbbb
Copy link
Owner

Hi there, I plan to add support for loading ESM configuration files in v1.11.0 next weekend.
I have released a next pre-release version ๐ŸŒŸ(v1.11.0-beta.1)๐ŸŒŸ for testing.
Welcome to try it out! ๐Ÿ‘€ Let me know if there are still any issues. ๐ŸŽ‰

Docs preview link: https://deploy-preview-197--cz-git.netlify.app/config/
Example: https://github.com/Zhengqbbb/czgit-playground/tree/commitizen-esm

@Zhengqbbb
Copy link
Owner

Hi there ๐Ÿ‘‹
The latest version ๐ŸŒŸ(v1.11.0)๐ŸŒŸ released and supported ESM configure loading.
Docs Link: https://cz-git.qbb.sh/config/
๐Ÿ’ช Please have a try. ๐Ÿ‘€ Let me know if there are still any issues. ๐ŸŽ‰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not bug | wontfix This is't cz-git bug
Projects
None yet
Development

No branches or pull requests

2 participants