commitlint: Using config example gives error running 19.0.3
Steps to Reproduce
- Install commitlint and set up config (ref https://commitlint.js.org/reference/configuration.html)
npm install -g @commitlint/cli @commitlint/config-conventional
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
- Run commitlint
Current Behavior
Results in …
@commitlint/cli@19.0.3
file:///usr/local/lib/node_modules/@commitlint/cli/lib/cli.js:129
throw err;
^
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/usr/local/lib/node_modules/@commitlint/config-conventional' is not supported resolving ES modules imported from /usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js
Did you mean to import "/usr/local/lib/node_modules/@commitlint/config-conventional/lib/index.js"?
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:908:10)
at defaultResolve (node:internal/modules/esm/resolve:1131:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
at ModuleLoader.import (node:internal/modules/esm/loader:322:34)
at importModuleDynamically (node:internal/modules/esm/translators:159:35)
at importModuleDynamicallyCallback (node:internal/modules/esm/utils:207:14)
at dynamicImport (file:///usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/resolve-extends/lib/index.js:21:88) {
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
url: 'file:///usr/local/lib/node_modules/@commitlint/config-conventional'
}
Node.js v21.6.2
Expected Behavior
Before 19.0.0 it resulted in …
@commitlint/cli@18.6.1
96⧗ input: test: testing something
97✔ found 0 problems, 0 warnings
98= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
99### TEST PASSED (commitlint): Valid commit message passed
100### TEST START (commitlint): Testing invalid commit message
101[main 393de5d] invalid commit
102 Date: Thu Feb 22 05:44:52 2024 +0000
103 1 file changed, 1 insertion(+), 1 deletion(-)
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
No response
Context
I’m running CI/CD pipelines with many of my software projects and this was picked up in our commitlint job test.
commitlint --version
git --version
v2.44.0
node --version
21.6.2 (fails on 18 & 20 that I test too)
About this issue
- Original URL
- State: open
- Created 4 months ago
- Reactions: 2
- Comments: 22 (13 by maintainers)
Commits related to this issue
- ci: commitlint correct usage old docs outdated conventional-changelog/commitlint#3947 — committed to TobiTenno/romcal by TobiTenno 3 months ago
It works: https://github.com/marcalexiei/commitlint-playground/actions/runs/8108167213/job/22160890870
In your package.json you are using v18 packages
https://github.com/ItsSunnyMonster/ruxel/blob/9709f3bdc30843d887146ae046d1cef583365f63/package.json#L3-L5
while on your run you GitHub action run you are installing
commitlint@latest
.commitlint@latest
is an alias forcommitlint/cli
so I think you got a version mismatch. Could you try using packages all v19 packages?@nkukard why not use
npx commitlint
instead ofcommitlint
, after installing without-g
? That would be an easy workaround for now.No probs.
My CI/CD pipeline for commitlint started failing when v19 was released. It was working before that with v18.
I’m not sure if maybe another dep may of been updated as I very briefly tried installing <v19.0.0 and it failed in the same way.
I’m currently using
export NODE_PATH=/usr/local/lib/node_modules
as a workaround in this specific case.I tried this locally and it’s working:
I also setup a simple GitHub Action and I’m unable to reproduce the issue:
https://github.com/marcalexiei/commitlint-playground/actions/runs/8101865722/job/22143073353