Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install in ubuntu 14.04 #88

Closed
akshay194 opened this issue Aug 8, 2017 · 10 comments
Closed

Unable to install in ubuntu 14.04 #88

akshay194 opened this issue Aug 8, 2017 · 10 comments

Comments

@akshay194
Copy link

I tried installing it in Ubuntu 14.04 but it does not work, please help.

$ sudo npm install ngrok -g
npm http GET https://registry.npmjs.org/ngrok
npm http 304 https://registry.npmjs.org/ngrok
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/decompress-zip
npm http GET https://registry.npmjs.org/lock
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/uuid
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/decompress-zip
npm http 304 https://registry.npmjs.org/lock
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/uuid
npm http GET https://registry.npmjs.org/types/node
npm http 404 https://registry.npmjs.org/types/node
npm ERR! TypeError: Cannot read property 'latest' of undefined
npm ERR!     at next (/usr/share/npm/lib/cache.js:687:35)
npm ERR!     at /usr/share/npm/lib/cache.js:675:5
npm ERR!     at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR!     at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 4.4.0-87-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "ngrok" "-g"
npm ERR! cwd /home/akshay
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! type non_object_property_load
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/akshay/npm-debug.log
npm ERR! not ok code 0

@bubenshchykov
Copy link
Owner

boooo (
404 https://registry.npmjs.org/types/node - can it be an npm glitch
Anyway, I updated ngrok on npm 20 seconds ago, can you try latest please

@bubenshchykov
Copy link
Owner

bubenshchykov commented Aug 8, 2017

Hey I just noticed that your environment is quite outdated!
node -v v0.10.25, npm -v 1.3.10 - you can expect plenty of bugs or misbehaviors :) Many modules require higher versions.

try to update both npm i npm -g and node, if that's possible

@akshay194
Copy link
Author

Tried after update, getting this:

$sudo npm install ngrok -g
/usr/bin/ngrok -> /usr/lib/node_modules/ngrok/bin/ngrok

> [email protected] postinstall /usr/lib/node_modules/ngrok
> node ./postinstall.js

ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/ngrok.zip'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/akshay/.npm/_logs/2017-08-08T10_58_16_164Z-debug.log

Node and npm version:

$ node -v
v8.2.1
$ npm -version
5.3.0

@bubenshchykov
Copy link
Owner

Yep, that's still unsolved :(
duplicate of #87
can you try sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} as npm suggests https://docs.npmjs.com/getting-started/fixing-npm-permissions

@bubenshchykov
Copy link
Owner

@gaoqiankun another report. do you have an idea what's wrong with permissions here?

@gaoqiankun
Copy link
Contributor

gaoqiankun commented Aug 9, 2017

I tried reproduce this issue, after many times failure, i finally reproduce it successfuly

❯ sudo npm install -g ngrok                                                                                                                                                                               
/usr/bin/ngrok -> /usr/lib/node_modules/ngrok/bin/ngrok
> [email protected] postinstall /usr/lib/node_modules/ngrok
> node ./postinstall.js

ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/ngrok.zip'
    at Error (native)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-09T06_33_34_927Z-debug.log

I still can not undestand, why this happened, so I tried install an old version that before my code merged, then I got same problem, the only dirrerence is you catch the error, ant print it

[vagrant@postgres-mastrer] ~/work/ngrok (master) ⚡
❯ sudo npm install -g [email protected]                                                                                                                                                                        ⏎
/usr/bin/ngrok -> /usr/lib/node_modules/ngrok/bin/ngrok

> [email protected] postinstall /usr/lib/node_modules/ngrok
> node ./postinstall.js

ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip ...
ngrok - error downloading binary. { Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/bin/ngrok.zip'
    at Error (native)
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/lib/node_modules/ngrok/bin/ngrok.zip' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-09T06_52_21_421Z-debug.log

I suppose that it is npm‘s protecting mechanism, so i viewed npm source code, and find it

// https://github.com/npm/npm/blob/latest/lib/utils/lifecycle.js#runCmd#line225
var user = unsafe ? null : npm.config.get('user')
var group = unsafe ? null : npm.config.get('group')

npm will clear master process's user and group if it think the subprocess is unsafe when it run lifecyle commands

❯ su root
Password:
root@postgres-mastrer:/home/vagrant/work# npm i -g ./ngrok
/usr/bin/ngrok -> /usr/lib/node_modules/ngrok/bin/ngrok

> [email protected] postinstall /usr/lib/node_modules/ngrok
> node ./postinstall.js

==========================================
current process uid: 65534
current process gid: 0
current process euid: 65534
current process egid: 0
==========================================
ngrok - unpacking binary
ngrok - error unpacking binary { Error: EACCES: permission denied, open '/home/vagrant/work/ngrok/bin/ngrok'
    at Error (native)
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/home/vagrant/work/ngrok/bin/ngrok' }
ngrok - install failed, retrying
ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
ngrok - downloading progress: 3975633/5363700^C
root@postgres-mastrer:/home/vagrant/work# ll
total 12
drwxrwxr-x 3 vagrant vagrant 4096 Aug  9 06:29 ./
drwxr-xr-x 9 vagrant vagrant 4096 Aug  9 10:26 ../
drwxrwxr-x 6 vagrant vagrant 4096 Aug  9 10:26 ngrok/
root@postgres-mastrer:/home/vagrant/work#
root@postgres-mastrer:/home/vagrant/work# id
uid=0(root) gid=0(root) groups=0(root)

And /usr/lib/node_modules module

root@postgres-mastrer:/home/vagrant/work# ll /usr/lib/node_modules/
total 12
drwxr-xr-x  3 root root 4096 Aug  9 10:29 ./
drwxr-xr-x 76 root root 4096 Aug  9 06:27 ../
drwxr-xr-x 11 root root 4096 Aug  9 06:28 npm/

I will handler createstream permission error, and I found this little syntax bug will cause compatible problem

readStream
    .pipe(fs.createWriteStream(localFile))
    .on('finish', () => extract(cb));

It is my fault, i will fix it and create a pull request.

@bubenshchykov
Copy link
Owner

@gaoqiankun thx a lot for investigation!

@miquelbeltran
Copy link

Don't do sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} as it might change the owner of everything inside /usr/bin, including sudo and you won't be able to repair the error without a full reinstall. This happens because npm config get prefix can be /usr

@bubenshchykov
Copy link
Owner

might be fixed in 2.2.19, @akshay194 can you try again?

@bubenshchykov
Copy link
Owner

should be fixed! feel free to re-open in needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants