npm / npm/cli

[Bug] npm "Exit handler never called" in Node 22/24 Alpine Docker builds

Open
#8,974 2 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

npm ci and npm install fail with "Exit handler never called!" error when using Node.js 22 or 24 with Alpine Linux in Docker builds. Node.js 20 works correctly with the same configuration.

Error Message

docker build -t docs-agent:test-v24 .

[+] Building 83.1s (9/15)                                  docker:desktop-linux
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 686B                                       0.0s
 => [internal] load metadata for docker.io/library/node:22-alpine3.23      2.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 100B                                          0.0s
 => [ 1/11] FROM docker.io/library/node:22-alpine3.23@sha256:e4bf2a82ad0a  0.0s
 => [internal] load build context                                          0.0s
 => => transferring context: 1.65kB                                        0.0s
 => CACHED [ 2/11] WORKDIR /app                                            0.0s
 => CACHED [ 3/11] COPY package.json ./                                    0.0s
 => CACHED [ 4/11] COPY package-lock.json ./                               0.0s
 => ERROR [ 5/11] RUN npm install --omit=dev --no-audit                   81.0s
------                                                                          
 > [ 5/11] RUN npm install --omit=dev --no-audit:
80.97 npm error Exit handler never called!
80.97 npm error This is an error with npm itself. Please report this error at:
80.97 npm error   <https://github.com/npm/cli/issues>
80.97 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-02-10T18_34_53_580Z-debug-0.log
------
Dockerfile:12
--------------------
  10 |     
  11 |     # Install dependencies
  12 | >>> RUN npm install --omit=dev --no-audit
  13 |     
  14 |     # Copy source code
--------------------
ERROR: failed to solve: process "/bin/sh -c npm install --omit=dev --no-audit" did not complete successfully: exit code: 1

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/yj0zgzmkm0e1by643aw1o431e

Environment

  • Host OS: macOS (Docker Desktop)
  • Container OS: Alpine Linux
  • Docker: Docker Desktop (Linux containers)

Versions Tested

✅ Working
  • node:20-alpine3.21 - Works correctly
  • node:20.19.5-alpine3.21 - Works correctly
❌ Failing
  • node:22-alpine3.21 - Fails
  • node:22-alpine3.22 - Fails
  • node:22-alpine3.23 - Fails
  • node:24-alpine3.23 - Fails
  • node:24.13.0-alpine3.23 - Fails
npm Versions Tested (all failed)
  • npm 9.6.6 (downgraded)
  • npm 9.9.4 (downgraded)
  • npm 10.8.1 (downgraded)
  • npm 10.8.2+ (bundled with Node 22/24)

Steps to Reproduce

  1. Use the following Dockerfile:
FROM node:24.13.0-alpine3.23@sha256:cd6fb7efa6490f039f3471a189214d5f548c11df1ff9e5b181aa49e22c14383e

WORKDIR /app

COPY package.json ./
COPY package-lock.json ./

RUN npm ci --omit=dev --no-audit
  1. Build the image:
docker build -t test .
  1. Error occurs during the npm ci step

Expected Behavior

npm ci should install dependencies successfully, matching the behavior of Node.js 20.

Actual Behavior

npm crashes with "Exit handler never called!" error, causing the Docker build to fail.

package.json Details

  • lockfileVersion: 3
  • Node engines: >=20.0.0
  • Dependencies: 13 production dependencies
  • Dev dependencies: 6 dev dependencies

Key dependencies:

  • @ai-sdk/anthropic: ^1.2.12
  • @ai-sdk/google: ^1.2.19
  • @ai-sdk/openai: ^1.3.22
  • @modelcontextprotocol/sdk: ^1.10.2
  • express: ^5.1.0
  • ai: ^4.0.0

Workarounds Attempted (All Failed)

  1. ✅ Downgrading npm to 9.6.6, 9.9.4, 10.8.1
  2. ✅ Clearing npm cache before install
  3. ✅ Using npm install instead of npm ci
  4. ✅ Trying different Alpine versions (3.21, 3.22, 3.23)
  5. ✅ Installing as root vs non-root user
  6. ✅ Using different Node 22/24 patch versions

Related Issues

Additional Context

  • The same package-lock.json (lockfileVersion 3) works correctly with Node.js 20
  • The error occurs regardless of npm version when using Node 22/24
  • The error occurs in both npm ci and npm install
  • The error is specific to Alpine Linux Docker builds
  • No network issues (packages can be fetched, error occurs during installation)

Minimal Reproduction

Create a minimal package.json:

{
  "name": "test",
  "version": "1.0.0",
  "dependencies": {
    "express": "^5.1.0"
  }
}

Generate package-lock.json with Node 20, then try building with Node 22/24 Alpine.

Impact

  • Severity: High - Blocks upgrading from Node 20 to Node 22/24
  • Workaround: Must stay on Node 20 LTS
  • Affected: All Docker builds using Node 22/24 with Alpine Linux

System Information

# From Docker container (when using Node 22/24)
node --version  # v22.x.x or v24.x.x
npm --version   # v10.x.x
cat /etc/alpine-release  # 3.21, 3.22, or 3.23

Notes

  • Node.js 20 LTS is supported until April 2026
  • This appears to be an npm CLI bug rather than a Node.js runtime issue
  • The bug affects reproducible Docker builds, which is critical for CI/CD pipelines

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Dockerfile, package.json, and package-lock.json shown in the report, then reproduce npm ci under node:22/24-alpine and node:20-alpine. Compare the behavior with npm/cli issues 7639, 7672, 7657, 7666, and 8156 to locate the relevant npm CLI area. Done means the minimal lockfile installs successfully on affected Alpine images without the exit-handler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, javascript, nodejs
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.