hammerkit

yarn

Install locked Node.js dependencies with yarn.

Install locked Node.js dependencies with yarn. The task runs in a node container and keeps node_modules as its output, so it is skipped when package.json and yarn.lock are unchanged.

.hammerkit.yaml
includes:
  yarn:
    git: https://github.com/no0dles/hammerkit.git
    ref: v1.16.0
    path: catalog/yarn

tasks:
  build:
    image: node:24-alpine
    deps: [yarn:install]
    cmds:
      - yarn build

Tasks

TaskWhat it doesReadsProduces
installInstall locked Node.js dependencies with yarn.package.json, yarn.locknode_modules

Inputs

InputDefaultMeaning
NODE_VERSION24Tag of the node image the install runs in, e.g. 22 or 24. The image is node:<NODE_VERSION>-alpine.
YARN_ARGS--frozen-lockfileArguments of yarn install. The image ships yarn 1; for yarn berry (2 and later) use a Node image that provides it and pass --immutable.

The entry

catalog/yarn/build.yaml
# Installs the locked dependencies of a Node.js project with yarn.
envs:
  # tag of the node image the install runs in
  NODE_VERSION: 24
  # arguments of `yarn install`; yarn berry (2+) uses --immutable instead
  YARN_ARGS: --frozen-lockfile

tasks:
  install:
    description: install the locked dependencies with yarn
    image: node:${NODE_VERSION}-alpine
    src: [package.json, yarn.lock]
    generates: [node_modules]
    cmds:
      - yarn install $YARN_ARGS

On this page