Skip to content

Node/Npm hooks still fails in Windows #2402

@cristianmatache

Description

@cristianmatache

search tried in the issue tracker

2351

describe your issue

On Windows I am still experiencing an issue similar to #2351 . I tried https://stackoverflow.com/questions/71939099/bitbucket-pipeline-error-installing-pre-commit-ts-lint but setting any version still fails with the same error.

I was running this from:
cmd as well as Git Bash, in a conda environment

I also tried using the system node (with node 16.3.0 and 18.2.0) too but then it complains about:

D:\workspace\cookiecutter-alpha-build-polyrepo-py>pre-commit run --all-files
[WARNING] The 'rev' field of repo 'https://github.com/maximevast/pre-commit-tslint' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.  Hint: `pre-commit autoupdate` often fixes this.
[INFO] Installing environment for https://github.com/maximevast/pre-commit-tslint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('d:\\miniconda3\\python.exe', '-mnodeenv', '--prebuilt', '--clean-src', '\\\\?\\C:\\Users\\Cristian Matache\\.cache\\pre-commit\\repov2e2zaal\\node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    Installing system node.js on win32 is not supported!

Check the log at C:\Users\Cristian Matache\.cache\pre-commit\pre-commit.log

pre-commit --version

pre-commit 2.19.0

.pre-commit-config.yaml

repos:
-   repo: https://github.com/maximevast/pre-commit-tslint
    rev: ''
    hooks:
    -   id: tslint
        language_version: 16.3.0

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 2.19.0
git --version: git version 2.31.0.windows.1
sys.version:
    3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
sys.executable: d:\miniconda3\python.exe
os.name: nt
sys.platform: win32

error information

An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\Cristian Matache\\.cache\\pre-commit\\repov2e2zaal\\node_env-16.3.0\\Scripts\\npm.CMD', 'install', '--dev', '--prod', '--ignore-prepublish', '--no-progress', '--no-save')
return code: 1
expected return code: 0
stdout:

    up to date, audited 1 package in 3s

    found 0 vulnerabilities

stderr:
    The system cannot find the path specified.
    The system cannot find the path specified.
    npm WARN install Usage of the `--dev` option is deprecated. Use `--include=dev` instead.

Traceback (most recent call last):
  File "d:\miniconda3\lib\site-packages\pre_commit\error_handler.py", line 73, in error_handler
    yield
  File "d:\miniconda3\lib\site-packages\pre_commit\main.py", line 389, in main
    return run(args.config, store, args)
  File "d:\miniconda3\lib\site-packages\pre_commit\commands\run.py", line 414, in run
    install_hook_envs(to_install, store)
  File "d:\miniconda3\lib\site-packages\pre_commit\repository.py", line 223, in install_hook_envs
    _hook_install(hook)
  File "d:\miniconda3\lib\site-packages\pre_commit\repository.py", line 79, in _hook_install
    lang.install_environment(
  File "d:\miniconda3\lib\site-packages\pre_commit\languages\node.py", line 111, in install_environment
    helpers.run_setup_cmd(prefix, local_install_cmd)
  File "d:\miniconda3\lib\site-packages\pre_commit\languages\helpers.py", line 51, in run_setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
  File "d:\miniconda3\lib\site-packages\pre_commit\util.py", line 146, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Users\\Cristian Matache\\.cache\\pre-commit\\repov2e2zaal\\node_env-16.3.0\\Scripts\\npm.CMD', 'install', '--dev', '--prod', '--ignore-prepublish', '--no-progress', '--no-save')
return code: 1
expected return code: 0
stdout:

    up to date, audited 1 package in 3s

    found 0 vulnerabilities

stderr:
    The system cannot find the path specified.
    The system cannot find the path specified.
    npm WARN install Usage of the `--dev` option is deprecated. Use `--include=dev` instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions