In one of my projects experimenting Circle CI with Firebase. In order to use the firebase
command for deployment purposes first the firebase-tools
needs to be installed.
In my config.yml file the following stands - simplified:
version: 2.1
orbs:
node: circleci/node@1.1.6
jobs:
install-and-build:
executor:
name: node/default
steps:
- node/with-cache:
steps:
- checkout
- run: npm install
- run: sudo npm install -g firebase-tools
- run: npm run-script build
deploy:
executor:
name: node/default
steps:
- node/with-cache:
steps:
- run: firebase --version
workflows:
build-and-deploy:
jobs:
- install-and-build:
requires:
- install-dependencies
- deploy:
requires:
- install-and-build
Issue:
Once the npm install -g firebase-tools
command is in different step then it does not recognize the firebase
command lately and throws the following error:
/bin/bash: firebase: command not found
I found a solution which eliminates the issue by moving the firebase-tools
install step before usage as:
- node/with-cache:
steps:
- run: sudo npm install -g firebase-tools
- run: firebase --version
Questions:
I would say that solution is just a workaround instead of a proper one like moving the firebase-tools
installation steps into the install-and-build
one and using in the deployment step. I tried already the following ideas firstly based on my research:
- Creating an
alias
asalias firebase="`npm config get prefix`/bin/firebase"
based on this SO question. - Running
npm get prefix
to figure out which folder is containing thefirebase
command based on this SO question. - Installing
firebase-tools
as a devDependency and usingsave_cache
andrestore_cache
option to read fromnode_modules
folder.
Probably the issue is something else what I don't see, none of them helped that much thus my questions:
- Is there any solution which helps the pipeline accessing the
firebase
command after installed in any previous steps? - Is it fine to have the
firebase-tools
installation step in the deployment step? For some reason I don't like that.
Could someone enlighten me about this topic? Any idea is appreciated, thank you!