Open akumar0212 opened 8 months ago
Please provide online reproduction, not just error messages, that doesn't help.
Our repo is seeing this issue as well on the latest release. Hopefully this is what you mean by online repo.
@JounQin
I have created a public repo that shows the issue: https://github.com/moran-inadvantage/commit_lint_issue_3950
Here is an example of the failure: https://github.com/moran-inadvantage/commit_lint_issue_3950/actions/runs/8287030551/job/22678414864
You can trigger a workflow that fails here: https://github.com/moran-inadvantage/commit_lint_issue_3950/actions/workflows/commit-validate.yml
@moran-inadvantag I don't think we support legacy node v14, node v18+ is required.
node v18+ is required.
Maybe we should detect the version before running, and fail fast in case it's too old?
Maybe we should detect the version before running, and fail fast in case it's too old?
Something like this? https://gist.github.com/knocte/f78f8f60800e54bce59110138389105b
Maybe we should detect the version before running, and fail fast in case it's too old?
Something like this? https://gist.github.com/knocte/f78f8f60800e54bce59110138389105b
@escapedcat @JounQin what do you guys think?
Hmm... Didn't engines
field warning about the incompatible usage? I'm not sure whether we need to check it another time.
Hmm... Didn't engines field warning about the incompatible usage? I'm not sure whether we need to check it another time.
If that was the case, wouldn't @moran-inadvantage have got a different error?
The warning is occurred on installation AFAIK.
This is the error you get when you install it with a wrong version:
user@machine ~/test npm install --save-dev @commitlint/{cli,config-conventional}
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/cli@19.2.1',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/config-conventional@19.1.0',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/format@19.0.3',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/lint@19.1.0',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/load@19.2.0',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/read@19.2.1',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/types@19.0.3',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'execa@8.0.1',
npm WARN EBADENGINE required: { node: '>=16.17' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/is-ignored@19.0.3',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
...
I think this should be enough, no?
So @moran-inadvantage didn't get this because he used it directly via npx
instead of installing?
Yeah, that could be the case:
user@machine ~/test npx @commitlint/cli
@commitlint/cli@19.2.1 - Lint your commit messages
[input] reads from stdin if --edit, --env, --from and --to are omitted
Options:
-c, --color toggle colored output [boolean] [default: true]
-g, --config path to the config file
...
So we need the "Unsupported engine" checks at runtime too, not just installation time.
Ah no, same. Forgot to delete the node_modules
in my test
folder...
user@machine ~/test npx @commitlint/cli
Need to install the following packages:
@commitlint/cli
Ok to proceed? (y) y
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@commitlint/cli@19.2.1',
npm WARN EBADENGINE required: { node: '>=v18' },
npm WARN EBADENGINE current: { node: 'v16.14.0', npm: '8.3.1' }
npm WARN EBADENGINE }
So why did @moran-inadvantage not get the above, @escapedcat ?
There is a warning, but the user didn't notice that I think.
So, should/can we convert that warning into an error?
Hm, can't decide.
On the one hand the warning seems to be the default in the ecosystem and people should be used to that?
On the other hand it might be nice to give a clear error.
Apparently other packages are also using different strategies:
npx prettier
prettier requires at least version 14 of Node, please upgrade
npx eslint
Oops! Something went wrong! :(
ESLint: 8.56.0
TypeError: Module.createRequire is not a function
at Object.<anonymous> (/test/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2404:26)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/test/node_modules/eslint/lib/cli-engine/cli-engine.js:33:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
The ideal would be the best of both worlds:
At least this way people would not report bugs that are related to this, and would try to upgrade first.
There's also "enginesStrict": true
, for when your code will definitely not work on old versions, like this. If, i.e., I dropped an old Node becuase it was old, you wouldn't set that, but if I dropped it becuase it doesn't work, then you would.
Steps to Reproduce
Current Behavior
Expected Behavior
Affected packages
Possible Solution
No response
Context
No response
commitlint --version
19.0.3
git --version
2.25.1
node --version
18.x