# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:7.10

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    steps:
      - checkout

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

      - run: npm i

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

      # run tests!
      - run: npm run test

version: 2

jobs:
  build-node-common: &build-node-common
    steps:
      - checkout

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

      - run:
          name: Install dependencies
          command: npm i

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

      - run:
          name: Test
          command: npm test

  build-node-6:
    <<: *build-node-common
    docker:
      - image: node:6

  build-node-7:
    <<: *build-node-common
    docker:
      - image: node:7

  build-node-8:
    <<: *build-node-common
    docker:
      - image: node:8

workflows:
  version: 2
  build_node_versions:
    jobs:
      - build-node-6
      - build-node-7
      - build-node-8

Build multiple node versions on CircleCI
Build multiple node versions on CircleCI
