Ngrok: npm installation fails

Created on 28 Jun 2017  路  25Comments  路  Source: inconshreveable/ngrok

As of today I can't install ngrok via npm, I get the following output on Debian with node 5.0.4:

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

> [email protected] postinstall /usr/local/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/local/lib/node_modules/ngrok/bin/ngrok.zip'
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/usr/local/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!     /root/.npm/_logs/2017-06-28T11_13_44_043Z-debug.log

Installation was working fine 10 days ago.

This also breaks the installation of https://github.com/expo/exp

Most helpful comment

This one did the trick for me:

sudo npm i -g ngrok --unsafe-perm=true --allow-root

All 25 comments

@bserem Same here, I used this installation method on my last machine a few months ago, but after reinstalling it yesterday it doesn't work anymore. I get the same error message.

Same issue here on Mac OS Sierra, npm 5.3.0

Managed to install it by using yarn instead of npm
In my case I was installing ngrok with exp, so I used yarn global add exp

I was having the same issue with npm install -g exp.
I also tried with yarn global add exp and it didnt work.
What worked was installing ngrok through yarn "yarn global add ngrok" and then "yarn global add exp" and it worked

for node installs on linux mint and ubuntu where it gets installed in /usr/bin/node and /usr/lib/node_modules, this did the trick for me:

$sudo yarn global add ngork --modules-folder /usr/lib/node_modules
$sudo yarn global add exp --modules-folder /usr/lib/node_modules

^^ Small typo on ngork (we want ngrok). It worked for me too! (Ubuntu)

Same problem here. Using Arch linux.

This is didn't work for me on a generic EC2 Linux AMI but I have it working on another EC2 Linux AMI where it works perfectly. Both instances are setup the same way but for some reason this one will not let me setup ngrok. I get the same exact error that started this thread. I've tired as root several times and rebooted, no idea whats up. Same versions between each instance.

The same for my on Windows 10, I test with npm and yarn, download fine the package and never end of unpack . Any Idea of what happen??

Same issue here... I was hoping this has been fixed already.

Yeah I'm experiencing this on a brand new Ubuntu build within an ESXI environment.

Same here, brand new Ubuntu build Xenial under virtualbox

Yeah, so I downloaded ngrok directly from the source on my Ubuntu machine using wget and unzipped and placed within the usr/local/ folder and it works like a charm now.

Forrest whatever reason downloading via package manager ngrok fails.

I removed sudo from the beginning of the command and it installed with npm (was failing with sudo)! BTW, I was installing "sudo npm install exp --global" when I saw the above error mentioned above.

sudo chown -R $(whoami) /usr/{lib/node_modules} should work.

@ankibalyan doesn't work on MacOS High Sierra

This one did the trick for me:

sudo npm i -g ngrok --unsafe-perm=true --allow-root

brezzhnev...that also worked for me.

@brezzhnev This is the answer. But why is this now necessary and can it be fixed?

@brownbl1 just grabbed from here: https://github.com/appium/appium/issues/10293#issuecomment-370334351

Actually, have no idea, would like to ask this question to devs as well :)

For me, npm is like a black box, you never know what could happen whenever you try to install or update dependencies.

sudo npm i -g ngrok --unsafe-perm=true --allow-root

livesafer!

I just saw one line with sudo, unsafe and allow-root... This is what nightmares are made of

Same problem on Windows 10. Will this be fixed?

npm install ngrok --unsafe-perm=true --save

It only works with unsafe-perm param.

This one did the trick for me:

sudo npm i -g ngrok --unsafe-perm=true --allow-root

It worked for me... great, thanks

Chiming in here in 2020 - still the same issue of not being able to find module postinstall.js

I'm on a Ubuntu 16.04.6 LTS machine, Node 12.17.0 via NVM

Surely passing sudo, --unsafe-perm=true, and --allow-root cannot be the answer?

EDIT: Just found https://github.com/bubenshchykov/ngrok/issues/115#issuecomment-380927124

It looks like until postinstall.js is removed, Linux and macOS users have to do it this way.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Conansoloman picture Conansoloman  路  7Comments

zero-master picture zero-master  路  6Comments

alexforever86 picture alexforever86  路  5Comments

IngwiePhoenix picture IngwiePhoenix  路  7Comments

ricardopieper picture ricardopieper  路  3Comments