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
aliasasalias firebase="`npm config get prefix`/bin/firebase"based on this SO question. - Running
npm get prefixto figure out which folder is containing thefirebasecommand based on this SO question. - Installing
firebase-toolsas a devDependency and usingsave_cacheandrestore_cacheoption to read fromnode_modulesfolder.
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
firebasecommand after installed in any previous steps? - Is it fine to have the
firebase-toolsinstallation 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!