Express.js For CircleCI

Hi guys I am trying to set up CircleCI for a Express.js project. When I used the default config file.

# 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

    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

However when I try building this project I get some cache errors.

Error computing cache key: template: cacheKey:1:19: executing "cacheKey" at <checksum "package.js...>: error calling checksum: open /home/circleci/repo/package.json: no such file or directory

Error computing cache key: template: cacheKey:1:19: executing "cacheKey" at <checksum "package.js...>: error calling checksum: open /home/circleci/repo/package.json: no such file or directory

Finally I get this error.

#!/bin/bash -eo pipefail
yarn test
yarn test v0.24.4
error Couldn't find a package.json file in "/home/circleci/repo"
Exited with code 1

In the config file when I change the working directory it doesn’t seem to make a difference.

I’d assume that ~/repo/package.json does not exist. After your checkout step, try adding

- run: ls -l ~/repo

to see if the file is indeed part of your repo. Maybe it’s not committed?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.