Firebase: Can't finde npm package



While trying npm install firebase-tools and executing firebase deploy in my deploy workflow I get the following error message:

#!/bin/bash -eo pipefail
firebase deploy --token=$FIREBASE_DEPLOY_TOKEN
/bin/bash: firebase: command not found
Exited with code 127

Installing globally with sudo npm -g firebase-tools has also lead to an error message, since I apparently don’t have the rights to do so.

Im glad, if anyone can help!

The circle.yml file we’re talking about looks like this:

version: 2

  - image: circleci/node:9.5.0-stretch
  - checkout

  - restore_cache:
        # Find a cache corresponding to this specific package.json checksum
        # when this file is changed, this key will fail
        - v1-npm-deps-{{ checksum "package.json" }}
        # Find the most recent cache used from any branch
        - v1-npm-deps-
  - run: npm install

  - save_cache:
      key: v1-npm-deps-{{ checksum "package.json" }}
        - ./node_modules

  - run: npm run build

  - image: circleci/node:9.5.0-stretch
  - run: npm install firebase-tools
  - run:
      name: Deploy Master to Firebase
      command: firebase deploy --token=$FIREBASE_DEPLOY_TOKEN
  version: 2
  - build-job:
          only: stage
  - deploy-job:
          only: master


I’d guess that npm installs the binary in a location not covered by the system PATH. Do you know what location npm installs things to - maybe /usr/local/bin? Find this out and then modify firebase to include the full path.

You can fail this job and connect with SSH to do some investigation, if that’s easier.


Thank you for this hint! changing the command to
- run: name: Deploy Master to Firebase command: ./node_modules/.bin/firebase deploy --token=$FIREBASE_DEPLOY_TOKEN
has worked!

But now this command seems to be executed in the wrong location (not in the root folder): Error: Not in a Firebase app directory (could not locate firebase.json) Exited with code 1
Does anyone know how to solve that?


I assume the command will allow you to specify the app directory in a parameter/switch. Try it locally with --help to see what the available options are.

Or, given that the command seems to be sensitive to the dir it is run from, you could do:

ln -s ./node_modules/.bin/firebase . && \
    ./firebase deploy --token=$FIREBASE_DEPLOY_TOKEN

That will create a symlink in your app folder and then run the symlink.