mysql2 icon indicating copy to clipboard operation
mysql2 copied to clipboard

Error 'spawn git ENOENT' while installing types/mysql2

Open ivo-andrade-sity opened this issue 5 years ago • 16 comments

Hi! I'm fairly new with Node and Typescript in general and, while following a tutorial, I've encountered an issue trying to install types/mysql2 via the command npm i types/mysql2 -D

When running the command, I get the following error:

npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/types/mysql2.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\[redacted path]\AppData\Roaming\npm-cache\_logs\2019-07-24T21_06_57_398Z-debug.log

The log file reads as follows:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'types/mysql2',
1 verbose cli   '-D' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session ffaebe21627f68a6
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for github:types/mysql2 Error while executing:
7 silly fetchPackageMetaData undefined ls-remote -h -t ssh://[email protected]/types/mysql2.git
7 silly fetchPackageMetaData
7 silly fetchPackageMetaData
7 silly fetchPackageMetaData spawn git ENOENT
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 1172ms
10 verbose stack Error: spawn git ENOENT
10 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
10 verbose stack     at onErrorNT (internal/child_process.js:415:16)
10 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
11 verbose cwd C:\[redacted path, recipient folder for my DB]
12 verbose Windows_NT 10.0.17763
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "types/mysql2" "-D"
14 verbose node v10.16.0
15 verbose npm  v6.9.0
16 error path git
17 error code ENOENT
18 error errno ENOENT
19 error syscall spawn git
20 error enoent Error while executing:
20 error enoent undefined ls-remote -h -t ssh://[email protected]/types/mysql2.git
20 error enoent
20 error enoent
20 error enoent spawn git ENOENT
21 error enoent This is related to npm not being able to find a file.
22 verbose exit [ 1, true ]

Apparently it's an issue with the retrival of files from GitHub, but would like to be sure about it, since I've found nothing looking up for this issue. I appreciate the attention and help beforehand and hope you all are having a nice day! :)

ivo-andrade-sity avatar Jul 24 '19 21:07 ivo-andrade-sity

Just as a heads up, I've tried this on two different setups by now, one was an Amazon EC2 instance running Windows Server and the other was a desktop running Windows 10, both with their own distinct internet connections.

Also, for the ones interested, this is the tutorial I've been following and didn't manage to complete: https://www.youtube.com/watch?v=4clEduk6OQM

ivo-andrade-sity avatar Jul 25 '19 14:07 ivo-andrade-sity

Ok, this is more substancial now. I've instead tried to just add the dependency to the package.json of my project and run the command `npm install' instead. Here's my devDependencies:

"devDependencies": {
    [redacted, other devDependencies],
    "types/mysql2": "1.0.0"
  },

And then I get the following error for running npm install:

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "types/mysql2": name can only contain URL-friendly characters

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-07-25T15_50_39_439Z-debug.log

Did I make any errors trying to install the package this way? Is there any means to have it manually installed?

ivo-andrade-sity avatar Jul 25 '19 16:07 ivo-andrade-sity

Would it be you have a firewall blocking the connection? I have tried it and it is ok.

unional avatar Jul 25 '19 16:07 unional

npm i types/mysql2

...
+ @types/[email protected]
added 2 packages from 1 contributor and audited 3 packages in 4.623s
found 0 vulnerabilities

unional avatar Jul 25 '19 16:07 unional

I've shut down the firewall (at least for the Amazon instance I'm working at atm), but no luck, same error.

ivo-andrade-sity avatar Jul 25 '19 18:07 ivo-andrade-sity

I've been also attempting to use alternatives to the mysql2 while I'm facing this issue, but I'm also getting the same error while trying to install npm install mysqljs/mysql:

npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/mysqljs/mysql.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.

Here's the error log saved in my AppData folder:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'mysqljs/mysql' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 230f3c8bcdd16f91
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for github:mysqljs/mysql Error while executing:
7 silly fetchPackageMetaData undefined ls-remote -h -t ssh://[email protected]/mysqljs/mysql.git
7 silly fetchPackageMetaData
7 silly fetchPackageMetaData
7 silly fetchPackageMetaData spawn git ENOENT
8 timing stage:rollbackFailedOptional Completed in 0ms
9 timing stage:runTopLevelLifecycles Completed in 641ms
10 verbose stack Error: spawn git ENOENT
10 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
10 verbose stack     at onErrorNT (internal/child_process.js:415:16)
10 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
11 verbose cwd C:\Users\Administrator\Documents\Site-SITY-DB
12 verbose Windows_NT 10.0.17763
13 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "mysqljs/mysql"
14 verbose node v10.16.0
15 verbose npm  v6.9.0
16 error path git
17 error code ENOENT
18 error errno ENOENT
19 error syscall spawn git
20 error enoent Error while executing:
20 error enoent undefined ls-remote -h -t ssh://[email protected]/mysqljs/mysql.git
20 error enoent
20 error enoent
20 error enoent spawn git ENOENT
21 error enoent This is related to npm not being able to find a file.
22 verbose exit [ 1, true ]

ivo-andrade-sity avatar Jul 25 '19 18:07 ivo-andrade-sity

I'm also having trouble installing this module inside of my office. We have firewall rules explicitly preventing direct access to Github. Is there any way to install this through the npm registry instead?

SupernaviX avatar Oct 29 '19 14:10 SupernaviX

Fails on my companys CI server:

error	19-Nov-2019 21:48:29	npm ERR! code 128
error	19-Nov-2019 21:48:29	npm ERR! Command failed: git clone --mirror -q git://github.com/types/mysql2.git

Would be easier for us if we just could npm install @types/mysql2.

nekman avatar Nov 19 '19 21:11 nekman

Hi,

Good day!

I'm having the same error: Here is what I did: -disable firewall -update nodejs -clear cache of npm -deleting node_modules folder

BUT still problem exist upon running 'npm install' command.

C:\xampp\htdocs\my-project>npm install npm ERR! code ENOENT npm ERR! syscall spawn git npm ERR! path git npm ERR! errno ENOENT npm ERR! enoent Error while executing: npm ERR! enoent undefined ls-remote -h -t https://github.com/nhn/raphael.git npm ERR! enoent npm ERR! enoent npm ERR! enoent spawn git ENOENT npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

Please help.

Thank you.

jrjaca avatar Apr 11 '20 03:04 jrjaca

typings showing version 1.1.1 is available but github authentication is stopping to download this version. version 1.0.0 is downloadable but showing many internal import errors inside index.d.ts.

Also some event emitting errors are present for windows.

Very difficult for a typescript project to import 'mysql2/promise' due to type definitions

nmitra6 avatar Jun 11 '20 13:06 nmitra6

typings is deprecated. You should install using npm

unional avatar Jun 11 '20 19:06 unional

This package doesn't have a published package on npm so it installs directly from github.

Can you check that you have git installed and that it has access to your SSH key for access to github? Just doing git clone [email protected]:types/mysql2.git should verify this.

If you didn't intend to use SSH as an access mechanism you could update package.json to "@types/mysql2": "types/mysql2".

skunca avatar Jun 16 '20 05:06 skunca

I also encountered the same error

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -2
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/types/mysql2.git

winjay-yu-awx avatar Jul 02 '20 03:07 winjay-yu-awx

This package doesn't have a published package on npm so it installs directly from github.

Can you check that you have git installed and that it has access to your SSH key for access to github? Just doing git clone [email protected]:types/mysql2.git should verify this.

If you didn't intend to use SSH as an access mechanism you could update package.json to "@types/mysql2": "types/mysql2".

This solved it for me. Was building inside a docker container that did not have git 🤦

chpaulin avatar Jul 02 '20 21:07 chpaulin

Having to add git to the container just to install this one dependency is a pain. Me and probably many others will just uninstall the types. It'd be really useful being able to install it from npm.

LeoDoldan7 avatar Sep 03 '20 11:09 LeoDoldan7

This package doesn't have a published package on npm so it installs directly from github. Can you check that you have git installed and that it has access to your SSH key for access to github? Just doing git clone [email protected]:types/mysql2.git should verify this. If you didn't intend to use SSH as an access mechanism you could update package.json to "@types/mysql2": "types/mysql2".

This solved it for me. Was building inside a docker container that did not have git 🤦

Thanks for @chpaulin suggestion! I've tried an alternative method to run apk add --no-cache git in front of npm install when using alpine image in the Dockerfile, which also works!

Louis5499 avatar Sep 21 '20 10:09 Louis5499