使用Circleci将Gatsby部署到Firebase

问题描述 投票:1回答:1

我关注了这个博客,使用circleCI将我的Gatsby网站部署到Firebase

https://circleci.com/blog/automatically-deploy-a-gatsby-site-to-firebase-hosting/

config.yml文件如下

# CircleCI Firebase Deployment Config
version: 2
jobs:
  build:
    docker:
      - image: circleci/node:10
    working_directory: ~/gatsby-site
    steps:
      - checkout
      - restore_cache:
          keys:
            # Find a cache corresponding to this specific package-lock.json
            - v1-npm-deps-{{ checksum "package-lock.json" }}
            # Fallback cache to be used
            - v1-npm-deps-
      - run:
          name: Install Dependencies
          command: npm install
      - save_cache:
          key: v1-npm-deps-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: Gatsby Build
          command: npm run build
      - run:
          name: Firebase Deploy
          command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"

这导致了错误

#!/bin/bash -eo pipefail
./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
/bin/bash: ./node_modules/.bin/firebase: No such file or directory

Exited with code exit status 127
CircleCI received exit code 127

我以前没有使用过yml文件或专注于devop,因此还没有进行过一些挖掘。发现了其他一些与此问题有关的人,并建议使用工作区和工作流程。因此,我修改了yml文件来支持此功能

# CircleCI Firebase Deployment Config
version: 2
jobs:
  #build jobs
  build:
    docker:
      - image: circleci/node:10
    working_directory: ~/gatsby-site
    steps:
      - checkout
      - restore_cache:
          keys:
            # Find a cache corresponding to this specific package-lock.json
            - v1-npm-deps-{{ checksum "package-lock.json" }}
            # Fallback cache to be used
            - v1-npm-deps-
      - run:
          name: Install Dependencies
          command: npm install
      - save_cache:
          key: v1-npm-deps-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - persist_to_workspace:
          root: ./
          paths:
            - ./
      - run:
          name: Gatsby Build
          command: npm run build
      - persist_to_workspace:
          root: ./
          paths:
            - ./
  # deploy jobs
  deploy-production:
    docker:
      - image: circleci/node:10
    steps:
      - attach_workspace:
          at: ./  
      - run:
          name: Firebase Deploy
          command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
workflows:
  version: 2
  build:
    jobs:
    #build
      - build
    #deploy
      - deploy-production:
          requires:
            - build

同一期

#!/bin/bash -eo pipefail
./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
/bin/bash: ./node_modules/.bin/firebase: No such file or directory

Exited with code exit status 127
CircleCI received exit code 127

我认为这一定与路径有关,并且它在错误的目录中查找?关于如何获取所需模块的任何想法吗?

firebase gatsby firebase-hosting circleci firebase-tools
1个回答
0
投票

显然,我看不懂。该修复程序在说明中

我们还需要在本地将firebase-tools软件包安装到我们的作为devDependency的项目。这将在以后的时间派上用场与CircleCI集成,不允许安装软件包默认为全局。因此,现在就安装它:

npm install -D firebase-tools

© www.soinside.com 2019 - 2024. All rights reserved.