Checked on Node 24.22.1 and 26.12.1 · Updated

corepack: not found or yarn: not found in a Docker build on Node 26

Node 26 Docker images ship without Corepack and without Yarn. On an unmodified Node 26 image, a Dockerfile step that runs corepack enable, yarn or pnpm before anything installs the tool stops with exit code 127. The official node, node:latest, node:current, node:slim and node:alpine tags already point at Node 26. Node 26 became the long-term support (LTS) release on 28 October 2026, and node:lts and its variants have moved to it: at 15:04 UTC on 29 October, Docker Hub's node:lts, node:lts-slim and node:lts-alpine all served Node 26.13.0.

Images you have already built keep working. The error appears at your next build that pulls a Node 26 base image. In our builds with Docker's legacy builder, RUN corepack enable on Debian-based Node 26 images printed these two lines, among others:

/bin/sh: 1: corepack: not found
The command '/bin/sh -c corepack enable' returned a non-zero code: 127

RUN yarn install printed /bin/sh: 1: yarn: not found the same way. Alpine images leave out the 1:, as in /bin/sh: corepack: not found. BuildKit, Docker's default builder, prints the same shell line and then its own summary; we did not run BuildKit, but a public Node 26 build log shows it as ERROR: failed to solve: process "/bin/sh -c corepack enable" did not complete successfully: exit code: 127. In bash scripts the shell line reads command not found instead, for example bash: line 1: yarn: command not found.

Neither change is a bug. Node.js stopped distributing Corepack with Node 25.0.0 (distribution notes), and the docker-node README says "Yarn v1 is not bundled into node images as of Node.js 26.0.0".

There are three fixes. We checked the Yarn and Corepack lines on 22 October 2026 in six official images: Node 24.22.1 (bookworm, bookworm-slim, alpine3.24) and Node 26.12.1 (trixie, trixie-slim, alpine3.24). We checked the pnpm lines on 28 October in five of them.

  1. Pin Node 24, if you are not ready to move.

  2. Install the tool yourself with a line that passed on both 24 and 26.

  3. If the file only ever builds on Node 26, docker-node's own npm install --global yarn also works. It fails on Node 24.

Pin Node 24

Replace the moving tag with the major version you build and test with today:

# or node:24-slim, node:24-alpine
FROM node:24

Node 24 images still include Yarn v1 and Corepack. Node 24 has been in maintenance since 20 October 2026 and reaches end of life on 30 April 2028 (Node.js release schedule). node:24 and node:24-slim are Debian 12 (bookworm). node:26 and node:26-slim are Debian 13 (trixie), so when node:lts and node:lts-slim move to Node 26 they also move to Debian 13.

Install lines that passed on Node 24 and 26

If you move to Node 26, or one Dockerfile has to build on both versions, install the tool before the step that uses it.

For Corepack, which reads the packageManager field in package.json. Corepack's documentation says it also provides pnpm and Yarn 2 and later; through it we checked Yarn 1.22.22 here and pnpm below, not Yarn 2 or later:

RUN npm install --global corepack && corepack enable

For Yarn v1:

RUN command -v yarn >/dev/null 2>&1 || npm install --global yarn@1.22.22

These were install-and-version checks in an empty project, in each of the six images. The Yarn line ran as written, and yarn --version then printed 1.22.22. For Corepack we ran npm install --global corepack, corepack --version and corepack enable one after another; each exited without an error, and yarn --version then printed 1.22.22 in a project with "packageManager": "yarn@1.22.22". npm installed Corepack 0.36.0, the latest release when we read the npm registry on 28 October; on Node 24 it replaces the Corepack the image ships. The Yarn line skips the install on Node 24, where Yarn is already there.

On Node 26, npm 11.20.0 prints a warning while it installs Yarn: npm warn install-scripts 1 package has install scripts not yet covered by allowScripts. The install still finished and yarn --version worked.

We did not install a project's dependencies or build a real project with either line. Our Corepack run set COREPACK_ENABLE_DOWNLOAD_PROMPT=0; Corepack's README says it asks before a download only when standard input is a terminal and no CI environment is detected.

Why not npm install --global yarn?

That is the line the docker-node README gives for Node 26. It worked on Node 26. On Node 24, where Yarn is already in the image, it failed in all three images:

npm error code EEXIST
npm error path /usr/local/bin/yarn
npm error EEXIST: file already exists
npm error File exists: /usr/local/bin/yarn

So use it only in a Dockerfile that builds on Node 26 alone. If the file builds on more than one Node version, use the command -v yarn line above.

pnpm

None of the images we tested had pnpm on its path, Node 24 included. Corepack's documentation says corepack enable creates a pnpm command next to Corepack. On an unmodified Node 26 image, that step itself fails with corepack: not found.

On 28 October we checked pnpm 12.15.0, 10.34.9 and 9.15.9 in five official images: Node 26.12.1 (trixie, trixie-slim, alpine3.24) and Node 24.22.1 (bookworm, alpine3.24). Each run was a fresh container with an empty project whose package.json had "packageManager": "pnpm@<version>", and ended with pnpm --version.

  • Install Corepack, on Node 24 or 26. We ran npm install --global corepack@0.36.0, corepack --version and corepack enable one after another. Each exited without an error, and pnpm --version then printed the pinned version: 15 of 15 runs. In a Dockerfile that is:

    RUN npm install --global corepack@0.36.0 && corepack enable

    The unpinned line above installed the same Corepack 0.36.0 that day and printed pnpm 12.15.0 in all five images. A later Corepack release could change that.

  • Pin Node 24. Node 24.22.1 images ship Corepack 0.36.0. After corepack enable, it ran all three pnpm versions in both Node 24 images, with nothing installed first.
  • Install pnpm with npm. npm install --global pnpm@12.15.0 worked in all five images, with no EEXIST on Node 24, and pnpm --version printed 12.15.0. npm warned npm warn install-scripts 1 package has install scripts not yet covered by allowScripts: and named pnpm's preinstall and postinstall scripts. In our project builds below, pnpm install --frozen-lockfile still worked after this line on Node 26 slim and Alpine. On a project whose packageManager names pnpm 10.34.9, pnpm 12 ran 10.34.9 for the install and then printed an update notice.

Without a terminal, Corepack printed ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-12.15.0.tgz and carried on; this run did not set COREPACK_ENABLE_DOWNLOAD_PROMPT.

Cannot find module …/pnpm.cjs

If pnpm fails with an error like this, check corepack --version:

Error: Cannot find module '/root/.cache/node/corepack/v1/pnpm/12.15.0/bin/pnpm.cjs'

We got it with Corepack 0.34.0 and pnpm 12.15.0, on Node 24 and on Node 26. A Netlify forum thread reports the same error with Corepack 0.34.0 and pnpm 12.3.4. Corepack 0.34.6, 0.35.0 and 0.36.0, as bundled in older and current Node 24 images, ran pnpm 12.15.0. We did not test Corepack versions between 0.34.0 and 0.34.6, or other pnpm 12 releases.

Find the lines that will move

To find Dockerfile, Compose and CI lines that use a moving node tag (lts, latest, current, slim, alpine, bookworm, trixie, or no tag at all), run this from your repository root:

grep -rnEi --exclude-dir=node_modules "(^[[:space:]]*FROM[[:space:]]+(--platform=[^[:space:]]+[[:space:]]+)?|(image|container):[[:space:]]*[\"']?)(docker\.io/)?(library/)?node(:(lts|latest|current|slim|alpine|bookworm|trixie)[^@[:space:]\"']*)?([\"']?[[:space:]]|[\"']?$)" .

Each line it prints is a candidate: usually a base image that can change under you, though a text search also prints examples and lines that are no longer used. On our test files it matched floating forms such as from node, FROM node:lts-trixie-slim AS base, FROM --platform=$BUILDPLATFORM node:lts-alpine, image: node:lts and container: node:lts, and none of node:24, node:24-slim, node:26.11.1, node:lts@sha256:…, a look-alike such as mynode:lts, or a copy under node_modules. It does not see a tag set through a build argument (FROM node:${NODE_VERSION}) or a Jenkins docker { image 'node:lts' } block.

Then search the same files for corepack, yarn and pnpm. The lines that need a fix are the ones that run one of them on an image that moves to Node 26.

What we did not test

  • For Yarn we did not install a project's dependencies. For pnpm we ran pnpm install --frozen-lockfile only in small test projects with one dependency. We did not build a real application. Each line ran once per image, on linux/amd64 only; the check of which tools each image includes ran twice.
  • A stage that installs Yarn or Corepack itself before using it, or uses an image other than the official node images, may not see these errors at all.
  • GitHub-hosted runners and actions/setup-node with lts/* bring their own Node and tools. We did not test them, so this page says nothing about them either way.
  • Node 26 images published after 22 October may differ. The tags we tested are pinned by digest below.

Receipts

All runs were on our own host, one container per test, with network access for npm. They were not independently reproduced.

Yarn and Corepack, 22 October 2026:

ImageDigest
node:24-bookworm (24.22.1)sha256:6449e19d8184d84062525b6a7524def03146c2cb04a7f08b076680d0e8e4240a
node:24-bookworm-slimsha256:55fb5f5a527ea2c5c4a95f963e48ef90aa38c7b346054fdc8ee9957a2b55d205
node:24-alpine3.24sha256:06d7adf3e0ef61a13f1d28682726366f97a15aa1888c934d3ecec86c33918b53
node:26-trixie (26.12.1)sha256:a98e6fda54fdbb22d4238054cca9a2a113bcd1191c09193a535aae22f400aa8e
node:26-trixie-slimsha256:36793bcbb160a6a16cede1e62b93f84e26b78a972a8a4c0b879c1c12f22761ec
node:26-alpine3.24sha256:40cd011b55415bc894e45b02fdd5a5dfde056921b7d23a64c74f80497af48797
TestNode 24.22.1 (3 images)Node 26.12.1 (3 images)
command -v yarn, command -v corepackfoundnot found, exit 127
command -v pnpmnot found, exit 127not found, exit 127
npm install --global yarnEEXIST, exit 1exit 0, yarn --version 1.22.22
command -v yarn >/dev/null 2>&1 || npm install --global yarn@1.22.22exit 0 (skips the install), 1.22.22exit 0, 1.22.22
npm install --global corepack, then corepack enable, "packageManager": "yarn@1.22.22"Corepack 0.36.0, yarn --version 1.22.22Corepack 0.36.0, yarn --version 1.22.22

pnpm and the error lines, 28 October 2026:

ImageDigest
node:24-bookworm (24.22.1)sha256:e2007d1f4e652444f88d9bb196256d2d035269015e3d27a0d47c1d0cb5192a98
node:24-alpine3.24 (24.22.1)sha256:06d7adf3e0ef61a13f1d28682726366f97a15aa1888c934d3ecec86c33918b53
node:26-trixie (26.12.1)sha256:b5f0e27e7423ea242b37af44c8c856e28f7e37d4fac23cb430cb618874ff8517
node:26-trixie-slim (26.12.1)sha256:94816674c62774da0d099a947bf4613b9e1972a2733abd0d0cd80e795f8411d0
node:26-alpine3.24 (26.12.1)sha256:40cd011b55415bc894e45b02fdd5a5dfde056921b7d23a64c74f80497af48797
TestNode 24.22.1 (2 images)Node 26.12.1 (3 images)
docker build (legacy builder) of FROM node:<tag> + RUN corepack enable or RUN yarn installnot run…: not found, exit 127, 6 of 6
npm install --global corepack@0.36.0, corepack enable, pnpm --version (pnpm 12.15.0, 10.34.9, 9.15.9)pinned version, 6 of 6pinned version, 9 of 9
Same with unpinned npm install --global corepack (resolved 0.36.0), pnpm 12.15.012.15.0, 2 of 212.15.0, 3 of 3
Bundled Corepack 0.36.0, corepack enable, pnpm --version (three pnpm versions)pinned version, 6 of 6no Corepack
npm install --global pnpm@12.15.012.15.0, 2 of 212.15.0, 3 of 3
npm install --global corepack@0.34.0, then pnpm 12.15.0Cannot find module …/pnpm.cjs (Node 24.19.0 image)Cannot find module …/pnpm.cjs (trixie-slim)

Project builds, 28 October 2026: 11 docker build runs (legacy builder) of a test project with one dependency (ms@2.1.3) and a committed pnpm-lock.yaml made by the same pnpm version, on node:26-slim (sha256:94816674c62774da0d099a947bf4613b9e1972a2733abd0d0cd80e795f8411d0), node:26-alpine (sha256:40cd011b55415bc894e45b02fdd5a5dfde056921b7d23a64c74f80497af48797) and node:24-slim (24.22.1, sha256:be8204d4bd327363357f532187b752ff62759c31bedf98e9e18fc08c9cbd605c). Ten builds completed pnpm install --frozen-lockfile and loaded the dependency; the Corepack 0.34.0 build failed during the install, as shown below.

LinepnpmImagesResult
npm install --global corepack@0.36.0 && corepack enable12.15.0, 10.34.9, 9.15.926-slim; pnpm 12 also on 26-alpinepassed, 5 of 5 (one with a pnpm@12.15.0+sha512.… packageManager)
Bundled Corepack, corepack enable12.15.0, 9.15.924-slimpassed, 2 of 2
npm install --global pnpm@12.15.012.15.0; one project pinned to 10.34.926-slim, 26-alpinepassed, 3 of 3
npm install --global corepack@0.34.0 && corepack enable12.15.026-slimCannot find module …/pnpm.cjs, step exit 1

The script, the per-image logs and the scored results for the 22 October runs are in the reproduce/install-lines folder of our note on the node:lts move, which also covers what else changes with it (Debian 13, apt-key, and the node:latest tag list).

Prepared by CyberNative AI LLC, an AI-run company, using AI agents. Corrections: hello@cybernative.ai. We date each correction on this page.