Firebase-tools: npm install -g firebase-tools fails but npm install -g [email protected] works

Created on 19 Nov 2019  路  4Comments  路  Source: firebase/firebase-tools

A few hours ago running npm install -g firebase-tools in our CI system started failing. We pinned to v7.7.0 to fix the issue.

Does not work

npm install -g firebase-tools

Works

npm install -g [email protected] works

[REQUIRED] Environment info

Docker Engine Version: 18.09.6
Kernel Version: Linux 95319c6db09e 4.15.0-1043-aws #45-Ubuntu SMP Mon Jun 24 14:07:03 UTC 2019 x86_64 Linux
Starting container google/cloud-sdk
  image is cached as google/cloud-sdk, but refreshing...
latest: Pulling from google/cloud-sdk
Digest: sha256:1323aeb05506dada2034d94e1bcd3504ca6e76263e68db1fac78d07fd22cc259
Status: Image is up to date for google/cloud-sdk:latest
  using image google/cloud-sdk@sha256:1323aeb05506dada2034d94e1bcd3504ca6e76263e68db1fac78d07fd22cc259

[REQUIRED] Test case

Run npm install -g firebase-tools in a google/cloud-sdk container

[REQUIRED] Steps to reproduce

npm install -g firebase-tools

[REQUIRED] Expected behavior

Tools install

[REQUIRED] Actual behavior

/root/.nvm/versions/node/v12.13.0/bin/firebase -> /root/.nvm/versions/node/v12.13.0/lib/node_modules/firebase-tools/lib/bin/firebase.js

> [email protected] postinstall /root/.nvm/versions/node/v12.13.0/lib/node_modules/firebase-tools/node_modules/protobufjs
> node scripts/postinstall

sh: 1: node: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/firebase-tools/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] postinstall: `node scripts/postinstall`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script

Most helpful comment

I have... news. First, I can replicate this. Yaaaayyyy.....

Second, I can put my finger on the fact that we now include @google-cloud/pubsub as a dependency for the emulators, which includes protobufjs. protobufjs was previously only a dev dependency, so it never would have run it's postinstall script in the container like this.

When running postinstall scripts, npm attempts to not run as root (for reasons). When running as root, npm will try to prevent the user from doing things that could have bad consequences. There is a parameter named unsafe-perm that can disable this.

Either run the npm install -g in the container as root with the --unsafe-perm flag (preferred, generally), or do npm config set unsafe-perm true somewhere before (which turns off this behavior everywhere, which wouldn't be desirable outside of a container, probably).

I hope that answers your question!

All 4 comments

I have... news. First, I can replicate this. Yaaaayyyy.....

Second, I can put my finger on the fact that we now include @google-cloud/pubsub as a dependency for the emulators, which includes protobufjs. protobufjs was previously only a dev dependency, so it never would have run it's postinstall script in the container like this.

When running postinstall scripts, npm attempts to not run as root (for reasons). When running as root, npm will try to prevent the user from doing things that could have bad consequences. There is a parameter named unsafe-perm that can disable this.

Either run the npm install -g in the container as root with the --unsafe-perm flag (preferred, generally), or do npm config set unsafe-perm true somewhere before (which turns off this behavior everywhere, which wouldn't be desirable outside of a container, probably).

I hope that answers your question!

Thanks that worked npm install --unsafe-perm -g firebase-tools

in my case this worked for me
npm install --unsafe-perm -g firebase-tools
then followed by
npm install --unsafe-perm -g firebase
and lastly
npm i firebase

bkendall, you rock! Your solution worked for me at once. Thanks for providing the explanation as well!

Was this page helpful?
0 / 5 - 0 ratings