用 yarn.lock 代替 package.lock

问题描述

我得到的错误

error computing cache key: template: cacheKey:1:30: executing "cacheKey" at <checksum "~/project/package-lock.json">: error calling checksum: open /home/circleci/project/package-lock.json: no such file or directory

我的 config.yaml 文件

version: 2.1
orbs:
  node: circleci/node@3.0.0
workflows:
  node-tests:
    jobs:
      - node/test

如何告诉 CircleCI 使用 yarn.lock 文件

解决方法

如果定义您自己的作业,您可以在作业的步骤中更改缓存键以使用 yarn.lockdocs 中的示例:

      - restore_cache:
          name: Restore Yarn Package Cache
          keys:
            - yarn-packages-{{ checksum "yarn.lock" }}
      - run:
          name: Install Dependencies
          command: yarn install --immutable
      - save_cache:
          name: Save Yarn Package Cache
          key: yarn-packages-{{ checksum "yarn.lock" }}
          paths:
            - ~/.cache/yarn