开发者问题收集

安装 nodegit 时出错

2021-01-02
2158

我正在尝试设置 nodejs,并意识到我需要链接到 git 存储库。我是个真正的新手,以前只使用过 html css 和 PHP。浏览网页后,我发现 nodegit 是一个可行的解决方案。它提示我输入 npm install nodegit 进行安装,但当我这样做时,我得到了一大堆错误。这是它开始报告错误时的日志文件。有人能帮忙吗?

1029 info run [email protected] install node_modules/nodegit node lifecycleScripts/preinstall && node lifecycleScripts/install
1030 info run [email protected] install { code: 1, signal: null }
1031 timing reify:rollback:createSparse Completed in 6751ms
1032 timing reify:rollback:retireShallow Completed in 228ms
1033 timing command:install Completed in 45271ms
1034 verbose stack Error: command failed
1034 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
1034 verbose stack     at ChildProcess.emit (node:events:376:20)
1034 verbose stack     at maybeClose (node:internal/child_process:1063:16)
1034 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
1035 verbose pkgid [email protected]
1036 verbose cwd C:\Javatest
1037 verbose Windows_NT 10.0.18363
1038 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "nodegit"
1039 verbose node v15.5.0
1040 verbose npm  v7.3.0
1041 error code 1
1042 error path C:\Javatest\node_modules\nodegit
1043 error command failed
1044 error command C:\Windows\system32\cmd.exe /d /s /c node lifecycleScripts/preinstall && node lifecycleScripts/install
1045 error [nodegit] Running pre-install script
1045 error [nodegit] Running install script
1045 error Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Javatest\node_modules\nodegit\build\Release\nodegit.node --module_name=nodegit --module_path=C:\Javatest\node_modules\nodegit\build\Release --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v88' (1)
1046 error node-pre-gyp
1046 error info it worked if it ends with ok
1046 error node-pre-gyp
1046 error info using [email protected]
1046 error node-pre-gyp
1046 error info using [email protected] | win32 | x64
1046 error node-pre-gyp WARN Using request for node-pre-gyp https download
1046 error
1046 error node-pre-gyp
1046 error info check checked for "C:\Javatest\node_modules\nodegit\build\Release\nodegit.node" (not found)
1046 error node-pre-gyp
1046 error http GET https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v88-win32-x64.tar.gz
1046 error node-pre-gyp http
1046 error 404 https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v88-win32-x64.tar.gz
1046 error node-pre-gyp WARN Tried to download(404): https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v88-win32-x64.tar.gz
1046 error node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v88 ABI, unknown) (falling back to source compile with node-gyp)
1046 error node-pre-gyp http 404 status code downloading tarball https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v88-win32-x64.tar.gz
1046 error
1046 error gyp
1046 error
1046 error info it worked if it ends with ok
1046 error gyp
1046 error info using [email protected]
1046 error gyp
1046 error info using [email protected] | win32 | x64
1046 error gyp
1046 error info ok
1046 error gyp
1046 error info
1046 error it worked if it ends with ok
1046 error gyp
1046 error info using [email protected]
1046 error gyp
1046 error info using [email protected] | win32 | x64
1046 error gyp
1046 error ERR! find Python
1046 error gyp ERR! find Python Python is not set from command line or npm configuration
1046 error gyp
1046 error ERR! find Python Python is not set from environment variable PYTHON
1046 error gyp ERR!
1046 error find Python checking if "python3" can be used
1046 error gyp ERR!
1046 error find Python - "python3" is not in PATH or produced an error
1046 error gyp ERR! find Python
1046 error checking if "python" can be used
1046 error gyp ERR! find Python - "python" is not in PATH or produced an error
1046 error gyp
1046 error ERR! find Python checking if "python2" can be used
1046 error gyp ERR! find Python - "python2" is not in PATH or produced an error
1046 error gyp ERR!
1046 error find Python checking if Python is C:\Python37\python.exe
1046 error gyp ERR!
1046 error find Python - "C:\Python37\python.exe" could not be run
1046 error gyp ERR! find Python checking if Python is C:\Python27\python.exe
1046 error gyp
1046 error ERR! find Python - "C:\Python27\python.exe" could not be run
1046 error gyp ERR!
1046 error find Python checking if the py launcher can be used to find Python
1046 error gyp ERR! find Python - "py.exe" is not in PATH or produced an error
1046 error gyp ERR! find Python
1046 error gyp
1046 error ERR! find Python **********************************************************
1046 error gyp ERR! find Python
1046 error You need to install the latest version of Python.
1046 error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
1046 error gyp
1046 error ERR! find Python you can try one of the following options:
1046 error gyp ERR!
1046 error find Python - Use the switch --python="C:\Path\To\python.exe"
1046 error gyp ERR! find Python
1046 error (accepted by both node-gyp and npm)
1046 error gyp ERR! find Python - Set the environment variable PYTHON
1046 error gyp
1046 error ERR! find Python - Set the npm configuration variable python:
1046 error gyp ERR!
1046 error find Python   npm config set python "C:\Path\To\python.exe"
1046 error gyp ERR! find Python
1046 error For more information consult the documentation at:
1046 error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
1046 error gyp
1046 error ERR! find Python **********************************************************
1046 error gyp ERR!
1046 error find Python
1046 error gyp
1046 error ERR! configure error
1046 error gyp
1046 error ERR! stack Error: Could not find any Python installation to use
1046 error gyp ERR! stack
1046 error at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:302:47)
1046 error gyp ERR! stack     at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
1046 error gyp
1046 error ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:200:18)
1046 error gyp ERR!
1046 error stack     at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:266:16)
1046 error gyp ERR! stack     at exithandler (node:child_process:340:5)
1046 error gyp
1046 error ERR! stack     at ChildProcess.errorhandler (node:child_process:352:5)
1046 error gyp
1046 error ERR! stack     at ChildProcess.emit (node:events:376:20)
1046 error gyp ERR!
1046 error stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:282:12)
1046 error gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
1046 error gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:80:21)
1046 error gyp
1046 error ERR! System Windows_NT 10.0.18363
1046 error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Javatest\\node_modules\\nodegit\\build\\Release\\nodegit.node" "--module_name=nodegit" "--module_path=C:\\Javatest\\node_modules\\nodegit\\build\\Release" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v88"
1046 error gyp ERR! cwd C:\Javatest\node_modules\nodegit
1046 error gyp
1046 error ERR! node -v v15.5.0
1046 error gyp
1046 error ERR! node-gyp -v v7.1.2
1046 error gyp ERR!
1046 error not ok
1046 error node-pre-gyp ERR!
1046 error build error
1046 error node-pre-gyp ERR!
1046 error stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Javatest\node_modules\nodegit\build\Release\nodegit.node --module_name=nodegit --module_path=C:\Javatest\node_modules\nodegit\build\Release --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v88' (1)
1046 error node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Javatest\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
1046 error node-pre-gyp
1046 error ERR! stack     at ChildProcess.emit (node:events:376:20)
1046 error node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1063:16)
1046 error node-pre-gyp
1046 error ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
1046 error node-pre-gyp ERR! System Windows_NT 10.0.18363
1046 error node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Javatest\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
1046 error node-pre-gyp ERR! cwd C:\Javatest\node_modules\nodegit
1046 error node-pre-gyp ERR! node -v v15.5.0
1046 error node-pre-gyp ERR! node-pre-gyp -v v0.13.0
1046 error node-pre-gyp ERR! not ok
1046 error [nodegit] ERROR - Could not finish install
1046 error [nodegit] ERROR - finished with error code: 1
1047 verbose exit 1
2个回答
1046 error ERR! find Python Python is not set from environment variable PYTHON
1046 error gyp ERR!
1046 error find Python checking if "python3" can be used
1046 error gyp ERR!
1046 error find Python - "python3" is not in PATH or produced an error

错误表示未安装 python,请安装 python 并将路径添加到 PYTHON 环境变量

PDHide
2021-01-02

您需要使用 node 版本 12 或更低版本。

或者,如果您想使用最新的 node,请按照平台的说明进行操作,它应该可以解决问题。 https://github.com/Automattic/node-canvas/wiki/_pages

我在 MacOS 和 Ubuntu 上遇到了同样的问题。两者都在最新节点上成功修复(目前是 22.3.0)

Denis Golubev
2024-07-04