我关注了这个博客,使用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
我认为这一定与路径有关,并且它在错误的目录中查找?关于如何获取所需模块的任何想法吗?
答案 0 :(得分:1)
显然我看不懂。解决方法在说明中
我们还需要在本地将firebase-tools软件包安装到我们的 作为devDependency的项目。这将在以后的时候派上用场 与CircleCI集成,不允许安装软件包 默认情况下是全局的。因此,现在就安装它:
npm install -D firebase-tools