greatcare / pm2-zabbix

A Node.js PM2 monitoring tool for Zabbix.
MIT License
87 stars 60 forks source link

npm install -g pm2-zabbix - Doesn't work #22

Open ghost opened 6 years ago

ghost commented 6 years ago

Hello I've try install your package and get this error:

32 verbose Linux 3.10.0-514.26.2.el7.x86_64
33 verbose argv "/usr/bin/node" "/bin/npm" "install" "-g" "pm2-zabbix"
34 verbose node v8.4.0
35 verbose npm  v5.3.0
36 error Error while executing:
36 error /bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git
36 error
36 error fatal: failed to stat '.': Permission denied
36 error
36 error exited with error code: 128
37 verbose exit [ 1, true ]

Like you can see, this command: /bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git - cannot execute if you don't have account (with pub key) on github

rkaw92 commented 6 years ago

Hm, interesting. Does the HTTPS protocol work for you from that host to any other host on the Web? I just tested with npm v5.3.0 and it correctly downloads the dependency without requiring ssh access to GitHub.

Supposedly, npm tries HTTPS first and then falls back to SSH if that fails for whatever reason. Maybe HTTPS is simply failing for you.

ghost commented 6 years ago

Yes, HTTPS work fine for that host. You can try reproduce with issue by using clear VM (ubuntu/centos) with latest node.

rkaw92 commented 6 years ago

Just checked with Docker image ubuntu, with latest Node. It seems to work fine and does not try to use ssh. Just to make sure, could you test whether your git can clone https repositories? git clone https://github.com/greatcare/node-zabbix-sender.git

Warfunck commented 6 years ago

Hi, i have the same problem: npm install -g --verbose pm2-zabbix npm info it worked if it ends with ok npm verb cli [ '/usr/bin/node', npm verb cli '/usr/bin/npm', npm verb cli 'install', npm verb cli '-g', npm verb cli '--verbose', npm verb cli 'pm2-zabbix' ] npm info using npm@5.6.0 npm info using node@v6.12.2 npm verb npm-session 7fc7a08e9da1a064 npm http fetch GET 304 https://registry.npmjs.org/pm2-zabbix 142ms (from cache) npm http fetch GET 304 https://registry.npmjs.org/bunyan 75ms (from cache) npm http fetch GET 304 https://registry.npmjs.org/pidusage 128ms (from cache) npm http fetch GET 304 https://registry.npmjs.org/minimist 132ms (from cache) npm http fetch GET 304 https://registry.npmjs.org/when 131ms (from cache) npm http fetch GET 304 https://registry.npmjs.org/pm2 137ms (from cache) npm verb stack Error: exited with error code: 128 npm verb stack at ChildProcess.onexit (/usr/lib/node_modules/npm/node_modules/mississippi/node_modules/end-of-stream/index.js:39:36) npm verb stack at emitTwo (events.js:106:13) npm verb stack at ChildProcess.emit (events.js:191:7) npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12) npm verb cwd /root npm verb Linux 4.9.0-4-amd64 npm verb argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "--verbose" "pm2-zabbix" npm verb node v6.12.2 npm verb npm v5.6.0 npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git npm ERR! npm ERR! fatal: failed to stat '.': Permission denied npm ERR! npm ERR! exited with error code: 128 npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-01-11T07_07_00_828Z-debug.log

Using debian 9.3 Linux name 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux

Warfunck commented 6 years ago

git clone https://github.com/greatcare/node-zabbix-sender.git Cloning into 'node-zabbix-sender'... remote: Counting objects: 206, done. remote: Total 206 (delta 0), reused 0 (delta 0), pack-reused 206 Receiving objects: 100% (206/206), 1.17 MiB | 0 bytes/s, done. Resolving deltas: 100% (89/89), done.

rkaw92 commented 6 years ago

@Warfunck I see. This seems to be an oddity in npm's resolving of modules tagged as github:. I have not been able to reproduce the above issue yet - suspecting something is on the local npm's end. Could you try to replicate exactly what npm is doing?

npm install -g github:greatcare/node-zabbix-sender#v0.3.0

The above command does work for me on npm@5.6.0 and also on other hosts with various npm versions. However, one difference I've noticed is this invocation: /usr/bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git

On my test machine, npm produces this instead: /usr/bin/git ls-remote -h -t git://github.com/greatcare/node-zabbix-sender.git

Surprisingly, both appear to work, although one of them (the latter) is clearly not using SSH.

Let's see what installing node-zabbix-sender (first command above) does for you, and if that fails, check where git ls-remote ... is going wrong.

Warfunck commented 6 years ago

Thank you for answering my question. That's what i got:

cat /root/.npm/_logs/2018-01-11T11_26_48_298Z-debug.log 0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', 1 verbose cli '/usr/bin/npm', 1 verbose cli 'install', 1 verbose cli '-g', 1 verbose cli '--verbose', 1 verbose cli 'github:greatcare/node-zabbix-sender#v0.3.0' ] 2 info using npm@5.6.0 3 info using node@v6.12.2 4 verbose npm-session 7da3c10c6cfabfd4 5 silly install loadCurrentTree 6 silly install readGlobalPackageData 7 silly fetchPackageMetaData error for github:greatcare/node-zabbix-sender#v0.3.0 Error while executing: 7 silly fetchPackageMetaData /usr/bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git 7 silly fetchPackageMetaData 7 silly fetchPackageMetaData fatal: failed to stat '.': Permission denied 7 silly fetchPackageMetaData 7 silly fetchPackageMetaData exited with error code: 128 8 verbose stack Error: exited with error code: 128 8 verbose stack at ChildProcess.onexit (/usr/lib/node_modules/npm/node_modules/mississippi/node_modules/end-of-stream/index.js:39:36) 8 verbose stack at emitTwo (events.js:106:13) 8 verbose stack at ChildProcess.emit (events.js:191:7) 8 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12) 9 verbose cwd /root 10 verbose Linux 4.9.0-4-amd64 11 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "--verbose" "github:greatcare/node-zabbix-sender#v0.3.0" 12 verbose node v6.12.2 13 verbose npm v5.6.0 14 error Error while executing: 14 error /usr/bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git 14 error 14 error fatal: failed to stat '.': Permission denied 14 error 14 error exited with error code: 128 15 verbose exit [ 1, true ]

AND

/usr/bin/git ls-remote -h -t ssh://git@github.com/greatcare/node-zabbix-sender.git Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

rkaw92 commented 6 years ago

So apparently npm is using SSH, instead of HTTP, for cloning the git repository, and failing for lack of public key (which is understandable). I have not yet been able to reproduce this behavior of npm myself, though - must investigate what causes it to choose one protocol (URL scheme) or the other. Do you perchance have a customized npm or git configuration?

Warfunck commented 6 years ago

We downgraded npm, installed the module, then updated it back. Now it s ok, thx a lot.

rkaw92 commented 6 years ago

Might be related: https://github.com/npm/npm/issues/19168

waeller commented 6 years ago

I have the same problem since we upgraded from node 6/npm 3 to node 8.9/npm 5.6, when doing "sudo npm -g install pm2-zabbix". However, "npm install pm2-zabbix" works.