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

npm global install on Ubuntu 17.10 fails #115

Closed
thisdavej opened this issue Apr 3, 2018 · 4 comments
Closed

npm global install on Ubuntu 17.10 fails #115

thisdavej opened this issue Apr 3, 2018 · 4 comments

Comments

@thisdavej
Copy link

Similar to issue#87, I cannot do an npm install of ngrok globally. I have tried it on Ubuntu 17.10 and Raspbian Stretch. Perhaps the issue was fixed and now it is broken again?

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

> ngrok@3.0.1 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 storing binary to local file { Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip'
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip' }
ngrok - install failed, retrying
ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
ngrok - error storing binary to local file { Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip'
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip' }
ngrok - install failed, retrying
ngrok - downloading progress: 36081/5363700ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
ngrok - error storing binary to local file { Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip'
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip' }
ngrok - install failed { Error: EACCES: permission denied, open '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip'
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/lib/node_modules/ngrok/bin/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1saW51eC1hbWQ2NC56aXA=.zip' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ngrok@3.0.1 postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ngrok@3.0.1 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/dave/.npm/_logs/2018-04-03T19_25_00_566Z-debug.log

Here's the npm debug log output:

2263 info lifecycle ngrok@3.0.1~postinstall: ngrok@3.0.1
2264 verbose lifecycle ngrok@3.0.1~postinstall: unsafe-perm in lifecycle false
2265 verbose lifecycle ngrok@3.0.1~postinstall: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/lib/node_modules/ngrok/node_modules/.bin:/usr/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
2266 verbose lifecycle ngrok@3.0.1~postinstall: CWD: /usr/lib/node_modules/ngrok
2267 silly lifecycle ngrok@3.0.1~postinstall: Args: [ '-c', 'node ./postinstall.js' ]
2268 silly lifecycle ngrok@3.0.1~postinstall: Returned: code: 1  signal: null
2269 info lifecycle ngrok@3.0.1~postinstall: Failed to exec postinstall script
2270 verbose unlock done using /home/dave/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
2271 verbose stack Error: ngrok@3.0.1 postinstall: `node ./postinstall.js`
2271 verbose stack Exit status 1
2271 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
2271 verbose stack     at EventEmitter.emit (events.js:180:13)
2271 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
2271 verbose stack     at ChildProcess.emit (events.js:180:13)
2271 verbose stack     at maybeClose (internal/child_process.js:936:16)
2271 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
2272 verbose pkgid ngrok@3.0.1
2273 verbose cwd /home/dave
2274 verbose Linux 4.13.0-21-generic
2275 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "ngrok"
2276 verbose node v9.10.1
2277 verbose npm  v5.6.0
2278 error code ELIFECYCLE
2279 error errno 1
2280 error ngrok@3.0.1 postinstall: `node ./postinstall.js`
2280 error Exit status 1
2281 error Failed at the ngrok@3.0.1 postinstall script.
2281 error This is probably not a problem with npm. There is likely additional logging output above.
2282 verbose exit [ 1, true ]
@bubenshchykov
Copy link
Owner

I don't think it was ever fixed. I thought that npm process creates /usr/lib/node_modules/ngrok/bin/, and then the same process writes .zip to it during postinstall. Apparently not. There are global installation tests running on Ubuntu 14 LTS, they are green and stable. https://travis-ci.org/bubenshchykov/ngrok/jobs/362082022#L681

So there are might be 17.10 specific things, or maybe a special local user-permissions setup that you have. Try to check who owns "/usr/lib/node_modules/ngrok/bin/" and who tries to write into it?

@thisdavej
Copy link
Author

I was able to solve this issue by running the npm global install with the --unsafe-perm flag:

$ sudo npm install --unsafe-perm -g ngrok

See more info on --unsafe-perm here.

By default, npm runs its lifecycle scripts (i.e. postinstall.js in our case here) as the nobody user rather than the regular user (root in our context since running under sudo). This enables postinstall.js to run as root so the ngrok bin file can get extracted successfully into /usr/lib/node_modules/ngrok and the installation can be completed without errors.

You might want to note this in the readme since I believe this fix is needed for anyone installing ngrok globally on Linux or OS X. This is not an issue for Windows since the global package will be installed in %AppData%\npm\node_modules without a problem.

@bubenshchykov
Copy link
Owner

@thisdavej great, I will update readme and then close this issue. Thanks a lot for your help!

ramilexe added a commit to ramilexe/transmute that referenced this issue May 4, 2018
@bubenshchykov
Copy link
Owner

bubenshchykov commented Jul 3, 2018

Added to readme https://github.com/bubenshchykov/ngrok/blob/master/README.md#usage
Thanks again @thisdavej for a detailed research!

Long term, I hope we'll get rid of posinstall.js and host ngrok binary on npm as individual os-restricted packages. #98

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

2 participants