Help us understand the problem. What is going on with this article?


More than 1 year has passed since last update.


  • リモートプッシュ時に Firebase のデプロイコマンドを実行したい


  • CircleCI環境下で、firebase のコマンド実行につまづいた


CI環境下で、Firebase のデプロイをしたいので、firebase-toolsをインストールする必要があります。


$ #!/bin/bash -eo pipefail
npm install -g firebase-tools
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/circleci/.npm/_logs/2018-09-28T03_37_43_747Z-debug.log
Exited with code 243



# Javascript Node CircleCI 2.0 configuration file
# Check for more details
version: 2
      - image: circleci/node:8

    working_directory: ~/repo

      - checkout

      # Download and cache dependencies
      - restore_cache:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: npm install
      - run:
          name: 'Install Dependecies'
          command: npm install --save-dev firebase-tools

      - save_cache:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run:
          name: 'Build Client Code(react-scripts によるビルド実行)'
          command: npm run build
      - run:
          name: 'Deploy to Hosting'
          command: >- 
              ln -s ./node_modules/firebase-tools/bin/firebase . &&
              ./firebase deploy --only hosting --project "$FIREBASE_PROJECT_ID" --token "$FIREBASE_TOKEN"

Firebase は、CI環境用に用意されたコマンドから、トークンを取得できるので、CircleCIにそれぞれFIREBASE_PROJECT_IDFIREBASE_TOKENを設定し、CIを走らせて、完了!

トッキョーで、ウェッブエンジニャーやってます。 フロントエンドやサーバレスまわりの技術が大好きなので、そこらへんでいろいろ知見を共有していきたいです🚀
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away