When programming, you may encounter the error โโgitโ is not recognized as an internal or external command,โ when installing packages, etc.
For example, below is an example where an error occurs when trying to install yo (yeoman).
> yo.cmd
? ==========================================================================
We're constantly looking for ways to make yo better!
May we anonymously report usage statistics to improve the tool over time?
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== No
? 'Allo ice! What would you like to do? Code
Make sure you are in the directory you want to scaffold into.
This generator can also be run with: yo code
_-----_ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
| | โ Welcome to the Visual โ
|--(o)--| โ Studio Code Extension โ
`---------ยด โ generator! โ
( _ยดU`_ ) โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
/___A___\ /
| ~ |
__'.___.'__
ยด ` |ยฐ ยด Y `
? What type of extension do you want to create? New Extension (TypeScript)
? What's the name of your extension? tmp
? What's the identifier of your extension? tmp
? What's the description of your extension?
? Initialize a git repository? Yes
? Bundle the source code with webpack? No
? Which package manager to use? npm
Writing in C:\pg\vscode\tmp...
create .vscode\extensions.json
create .vscode\launch.json
create .vscode\settings.json
create .vscode\tasks.json
create src\test\runTest.ts
create src\test\suite\extension.test.ts
create src\test\suite\index.ts
create .vscodeignore
create .gitignore
create README.md
create CHANGELOG.md
create vsc-extension-quickstart.md
create tsconfig.json
create src\extension.ts
create package.json
create .eslintrc.json
I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.
added 228 packages, and audited 229 packages in 22s
39 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Your extension tmp has been created!
To start editing with Visual Studio Code, use the following commands:
cd tmp
code-insiders .
Open vsc-extension-quickstart.md inside the new extension for further instructions
on how to modify, test and publish your extension.
For more information, also visit http://code.visualstudio.com and follow us @code.
'git' is not recognized as an internal or external command,
operable program or batch file.
_-----_ โญโโโโโโโโโโโโโโโโโโโโโโโโฎ
| | โ Bye from us! โ
|--(o)--| โ Chat soon. โ
`---------ยด โ Yeoman team โ
( _ยดU`_ ) โ http://yeoman.io โ
/___A___\ /โฐโโโโโโโโโโโโโโโโโโโโโโโโฏ
| ~ |
__'.___.'__
ยด ` |ยฐ ยด Y `
node:events:342
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at notFoundError (C:\Users\tmp\AppData\Roaming\npm\node_modules\generator-code\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\tmp\AppData\Roaming\npm\node_modules\generator-code\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\tmp\AppData\Roaming\npm\node_modules\generator-code\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess.cp.emit (C:\Users\tmp\AppData\Roaming\npm\node_modules\generator-code\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12) {
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn git',
path: 'git',
spawnargs: [ 'init', '--quiet' ]
}
As the error message indicates, this error can usually be resolved by installing โgitโ.
Download git as an executable file and install it normally, or install git using chocolatey.
choco install git -y
After installation, be sure to close and restart the shell (cmd.exe or powershell). This will confirm that typing the โgitโ command displays output, and verify that the same command that caused the error no longer produces the error.