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

Installation error in pre-commit with node version >22 #506

Open
dischii opened this issue Oct 30, 2024 · 2 comments
Open

Installation error in pre-commit with node version >22 #506

dischii opened this issue Oct 30, 2024 · 2 comments
Labels

Comments

@dischii
Copy link

dischii commented Oct 30, 2024

Installation error in pre-commit with node version >22

Summary

The installation markdownlint-cli in my pre-commit configuration does not work with the current version of node: v23.10.0.
In my Windows Environment in VSCode i can't execute the pre-commit with this package.

Error Message

[INFO] Installing environment for https://github.com/igorshubovych/markdownlint-cli.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\xxx\\.cache\\pre-commit\\repomtnety1c\\node_env-default\\Scripts\\npm.CMD', 'install', '--include=dev', '--include=prod', '--ignore-prepublish', '--no-progress', '--no-s
'--no-save')
return code: 1
stdout: (none)
stderr:
    (node:29492) ExperimentalWarning: CommonJS module C:\Users\xxx\.cache\pre-commit\repomtnety1c\node_env-default\Scripts\node_modules\npm\node_modules\debug\src\node.js is loading ES Module C:\Users\xxx\.cache\pre-commit\repomtnety1c\node1c\node_env-default\Scripts\node_modules\npm\node_modules\supports-color\index.js using require().
    Support for loading ES Module in require() is an experimental feature and might change at any time
    (Use `node --trace-warnings ...` to show where the warning was created)
    npm error code EBADENGINE
    npm error engine Unsupported engine
    npm error engine Not compatible with your version of node/npm: [email protected]
    npm error notsup Not compatible with your version of node/npm: [email protected]
    npm error notsup Required: {"node":"^18.18 || ^20.8 || ^21 || ^22"}
    npm error notsup Actual:   {"npm":"10.9.0","node":"v23.1.0"}
    npm error A complete log of this run can be found in: C:\Users\xxx\AppData\Local\npm-cache\_logs\2024-10-30T13_45_40_988Z-debug-0.log
Check the log at C:\Users\xxx\.cache\pre-commit\pre-commit.log

Possible but failed solution

Unfortunately, I didn't found any solution how to configure pre-commit to use an earlier node version.
I tried already the use of nvm but pre-commit use still the latest version v23.1.0:

nvm install 22.10.0
nvm use 22.10.0

Acceptance Criteria

  1. One solution is to support the newest version of node (v23.1.0) with this package
  2. Possible Workaround how to use different environments for local configuration of pre-commit (note: it wouldn't be a good solution for me to select the static version in the pre-commit-config.yaml file because it should be used from other participants and in my linux environment it is working sufficient)
@DavidAnson
Copy link
Collaborator

The underlying issue is a known problem the pre-commit team does not want tools like this to fix. You can read more in this issue (which links back to this repo eventually): DavidAnson/markdownlint-cli2#437

Your error message is different than the one I linked above (and present in a more recent duplicate of it), but fundamentally you want the tool to declare supported versions of Node and the pre-commit team forbid that.

So far as I know, what you suggest in option two at the bottom is the appropriate path forward. Or you might consider one of the proposals from the creator of the issue I link above.

Sorry about the trouble, I wish I understood why it has to be this way.

@DavidAnson
Copy link
Collaborator

Looking at this again, I do not see anything in the error messages above that points to this project being the cause. (Maybe the full log file has more to go on?)

The best I can guess is the version of ava being used declares itself unable to run on Node 23 and pre-commit is unwilling to use Node 22 instead. But this is irrelevant because ava is a devDependency and therefore not needed at runtime anyway.

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

No branches or pull requests

2 participants