【问题标题】:Deploy Gatsby to Firebase using Circleci使用 Circleci 将 Gatsby 部署到 Firebase
【发布时间】:2020-03-19 11:16:14
【问题描述】:

我按照这个博客使用 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 文件,也没有专注于 devops,所以我做了一些挖掘工作。发现其他几个人遇到了这个问题,并且有人建议使用工作区和工作流。所以我修改了我的 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-tools 是否列在您的package.json 中?
  • 你成就了我的一天! npm install -D firebase-tools 成功了

标签: firebase gatsby firebase-hosting circleci firebase-tools


【解决方案1】:

显然我无法阅读。修复在说明中

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

npm install -D firebase-tools

【讨论】:

    猜你喜欢
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多