我正在尝试安装eslint预提交挂钩(https://github.com/pre-commit/mirrors-eslint)
这是我的预提交文件中的条目:
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v7.4.0'
hooks:
- id: eslint
但是,当我运行pre-commit时,我得到以下信息:
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-eslint.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-eslint:eslint@7.4.0.
[INFO] Installing environment for https://github.com/pre-commit/mirrors-eslint.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('c:\\users\\username\\appdata\\local\\programs\\python\\python38\\python.exe', '-mnodeenv', '--prebuilt', '--clean-src', '\\\\?\\C:\\Users\\username\\.cache\\pre-commit\\repow421i8dr\\node_env-default')
Return code: 1
Expected return code: 0
Output: (none)
Errors:
* Install prebuilt node (14.5.0) ..... done.
symbolic link created for \\?\C:\Users\username\.cache\pre-commit\repow421i8dr\node_env-default\Scripts\nodejs.exe <<===>> node.exe
* Install npm.js (latest) ... Traceback (most recent call last):
File "c:\users\username\appdata\local\programs\python\python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\username\appdata\local\programs\python\python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\nodeenv.py", line 1462, in <module>
main()
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\nodeenv.py", line 1071, in main
create_environment(env_dir, opt)
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\nodeenv.py", line 911, in create_environment
instfunc(env_dir, src_dir, opt)
File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\nodeenv.py", line 762, in install_npm_win
shutil.copy(join(src_dir, npm_ver, 'bin', 'npm.cmd'),
File "c:\users\username\appdata\local\programs\python\python38\lib\shutil.py", line 415, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "c:\users\username\appdata\local\programs\python\python38\lib\shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '\\\\?\\C:\\Users\\username\\.cache\\pre-commit\\repow421i8dr\\node_env-default\\src\\npm-latest\\bin\\npm.cmd'
Check the log at C:\Users\username/.cache\pre-commit\pre-commit.log
我不知道该文件是什么,或者为什么eslint需要它。 当我直接从终端上使用Eslint时,它可以工作,这确认它是独立安装的,并且也可以正常工作。
答案 0 :(得分:0)
仅通过使用nodeenv,您应该能够在不进行预提交的情况下重现此崩溃-尝试以下操作:
nodeenv nenv --prebuilt --clean-src
我看到这是可能的唯一方法是,如果您有一个具有with_npm = true
和npm = ...
的nodeenv配置文件(某些非常老的npm版本没有提供{{ 1}}文件)
您可以尝试从配置文件中删除那些内容吗?我相信它可以在以下任何地方:
npm.cmd
./tox.ini
./setup.cfg