Error computing cache key: template

nodejs
circle.yml

#1

Hi,
I am trying to setup save cache. But i get the following error:

Error computing cache key: template: cacheKey:1:19: executing “cacheKey” at <checksum "package.js…>: error calling checksum: open /home/circleci/my-project/src/package.json: no such file or directory.

version: 2

machine:
    node:
        version: 8.9.4

jobs:
  build:
    docker:
      - image: circleci/node:8.9.4

working_directory: ~/my-project/src/

steps:
  - checkout:
      path: ~/my-project/src/

  - run:
      command: ls /home/circleci/my-project/src/

  - restore_cache:
      keys: v1-dependencies-{{ checksum "package.json" }}

  - run: npm install

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

  - run: npm run lint

I tried to see if there is package.json file ls /home/circleci/my-project/src/ and it shows another src folder inside this path /home/circleci/my-project/src/. I cannot understand this thing. I dont have any additional src folder inside this path.


#2

Is there a specific reason why you are using the working_directory arguments at all? If you leave all that stuff blank then it will just work based on the root of your repository. Try this:

steps:
  - checkout

  - run:
      command: ls /home/circleci/my-project/src/

  - restore_cache:
      keys: v1-dependencies-{{ checksum "package.json" }}

  - run: npm install

#3

I tried and now i get this error message:
ls: cannot access /home/circleci/my-project/src/ : No such file or directory
Exited with code 2. I also tried to check the root of the project itself.