windows npm 错误!在 $PATH 中找不到 git 二进制文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47967014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:01:21  来源:igfitidea点击:

npm ERR! No git binary found in $PATH

windowsgitnpmpathzenbot

提问by drhunn

I can't seem to get zenbot to install I am new to node.js, so please be kind. I am getting all kinds of error I do have git installed. I followed the install instructions and I really don't know where to start. I am a Java and C programming trying to cut my teeth on something new and learn through the bumps and bruises.

我似乎无法安装 zenbot 我是 node.js 的新手,所以请多多关照。我在安装 git 时遇到了各种错误。我按照安装说明进行操作,但我真的不知道从哪里开始。我是一名 Java 和 C 编程人员,试图在新事物上崭露头角,并通过颠簸和瘀伤来学习。

C:\zenbot>npm install
npm ERR! code ENOGIT
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\AppData\Roaming\npm-cache\_logs17-12-25T08_17_27_513Z-debug.log

----- Log file--
0 info it worked if it ends with ok
1 verbose cli [ 'C:\nodejs\node.exe',
1 verbose cli   'C:\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'install' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 5167d752483581f2
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall [email protected]
7 info lifecycle [email protected]~preinstall: [email protected]
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 silly install loadShrinkwrap
13 silly fetchPackageMetaData error for forex.analytics@github:mkmarek/forex.analytics#7bc278987700d4204e959af17de61495941d1a14 No git binary found in $PATH
14 verbose stack Error: No git binary found in $PATH
14 verbose stack     at checkGit (C:\nodejs\node_modules\npm\node_modules\pacote\lib\util\git.js:199:17)
14 verbose stack     at spawnGit (C:\nodejs\node_modules\npm\node_modules\pacote\lib\util\git.js:178:10)
14 verbose stack     at pinflight (C:\nodejs\node_modules\npm\node_modules\pacote\lib\util\git.js:110:12)
14 verbose stack     at C:\nodejs\node_modules\npm\node_modules\promise-inflight\inflight.js:29:24
14 verbose stack     at Promise._execute (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\debuggability.js:300:9)
14 verbose stack     at Promise._resolveFromExecutor (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:483:18)
14 verbose stack     at new Promise (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:79:10)
14 verbose stack     at _inflight (C:\nodejs\node_modules\npm\node_modules\promise-inflight\inflight.js:28:25)
14 verbose stack     at C:\nodejs\node_modules\npm\node_modules\promise-inflight\inflight.js:22:14
14 verbose stack     at tryCatcher (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
14 verbose stack     at Promise._settlePromiseFromHandler (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
14 verbose stack     at Promise._settlePromise (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
14 verbose stack     at Promise._settlePromiseCtx (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:606:10)
14 verbose stack     at Async._drainQueue (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:138:12)
14 verbose stack     at Async._drainQueues (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
14 verbose stack     at Immediate.Async.drainQueues (C:\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
15 verbose cwd C:\zenbot
16 verbose Windows_NT 10.0.15063
17 verbose argv "C:\nodejs\node.exe" "C:\nodejs\node_modules\npm\bin\npm-cli.js" "install"
18 verbose node v8.9.3
19 verbose npm  v5.5.1
20 error code ENOGIT
21 error No git binary found in $PATH
22 error Failed using git.
22 error Please check if you have git installed and in your PATH.
23 verbose exit [ 1, true ]


C:\WINDOWS\system32>git -v Unknown option: -v usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] –

回答by Chandre Gowda

You are trying within C:\WINDOWS\system32, probably gitexecutable is available over there.

您正在尝试C:\WINDOWS\system32,可能git可以在那里获得可执行文件。

Change the directory to C:\and then try git --version.

将目录更改为C:\,然后尝试git --version

If you get error gitis not recognized..., then gitpath is not set in environment variables.

如果您收到错误git无法识别...,则git路径未在环境变量中设置。

So, open your environment variable settings and set the git executable path to PATHvariable.

因此,打开您的环境变量设置并将 git 可执行路径设置为PATH变量。

回答by abahet

Looks like it's missing from the alpine image. npm install is kinda fundamental to node and git is required to install certain dependencies.

看起来它在高山图像中丢失了。npm install 是 node 的基础,安装某些依赖项需要 git。

Including

包含

RUN apk update && apk upgrade && \
    apk add --no-cache git

in the dockerfile will fix it.

在 dockerfile 中将修复它。