Nuxt.jsのプロジェクトにCircleCIを適用する #nuxtjs #circleci

概要

Nuxt.jsのプロジェクトをCircleCIで動かしてみる

config.ymlの作成

Nodeプロジェクト用ののテンプレートを利用してconfig.ymlを作成する

プロジェクトルートから .circleci/config.yml を作る。

$ mkdir .circleci
$ touch .circleci/config.yml

config.ymlは下記の通り。

version: 2
jobs:
  build:
    docker:
      # nodeのバージョンを上げておく
      - image: circleci/node:8.9.4

    working_directory: ~/repo

    steps:
      - checkout

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

      - run: yarn install

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

      # run tests!
      - run: yarn test

Nodeのバージョンを上げておく

テンプレート通りだと、imageは circleci/node:7.10 になっていたのだが、これだとNodeのバージョンが低くてエラーになる。

circleci/node:8.9.4 を使用するようにしたら解決した。

CircleCIのDockerHub

error nuxt@1.2.1: The engine "node" is incompatible with this module. Expected version ">=8.0.0".
error Found incompatible module

参考

circleci.com qiita.com