npm / npm/cli

[BUG] Problems with npm install in docker

Open
#8,572 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

Simple test application generated with npm init and npm install

I've already tried with node:24 node:22 node:18, I noticed that if I remove express from dependencies the error stops, I don't know if it's because nothing needs to be installed or if the problem is in express

I've tried with and without --no-update-notifier

{
"name": "psvo",
"version": "1.0.0",
"description": "SPA Example",
"license": "ISC",
"author": "",
"type": "module",
"main": "index.js",
"scripts": {
},
"dependencies": {
"express": "^5.1.0"
}
}

In Dockerfile

FROM node:22-alpine
WORKDIR /app
COPY package*.json .
RUN npm install --no-update-notifier
EXPOSE 80
CMD ["npm", "start"]

In docker compose

services:

  psvo-dev:
    container_name: psvo-dev
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    volumes:
      - /app/node_modules

When running docker compose build, npm install runs for a few minutes and issues the following error:

usuario@server:~/ecosistema1/services/psvo$ docker compose build
[+] Building 148.2s (9/9) FINISHED
 => [internal] load local bake definitions                                                                                                                         0.0s
 => => reading from stdin 537B                                                                                                                                     0.0s
 => [internal] load build definition from Dockerfile                                                                                                           0.0s
 => => transferring dockerfile: 207B                                                                                                                               0.0s
 => [internal] load metadata for docker.io/library/node:22-alpine                                                                                                  0.0s
 => [internal] load .dockerignore                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                    0.0s
 => [1/4] FROM docker.io/library/node:22-alpine                                                                                                                    0.0s
 => [internal] load build context                                                                                                                                  0.0s
 => => transferring context: 72B                                                                                                                                   0.0s
 => CACHED [2/4] WORKDIR /app                                                                                                                                      0.0s
 => [3/4] COPY package*.json .                                                                                                                                     0.2s
 => ERROR [4/4] RUN npm install --no-update-notifier                                                                                                             147.2s
------
 > [4/4] RUN npm install --no-update-notifier:
146.5 npm error Exit handler never called!
146.5 npm error This is an error with npm itself. Please report this error at:
146.5 npm error   <https://github.com/npm/cli/issues>
146.5 npm error A complete log of this run can be found in: /root/.npm/_logs/2025-09-16T16_05_37_926Z-debug-0.log
------
Dockerfile:7
--------------------

failed to solve: process "/bin/sh -c npm install --no-update-notifier" did not complete successfully: exit code: 1

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 package.json, Dockerfile, and docker compose configuration, then reproduce the failure with docker compose build using the listed Node images. Compare the install with and without express and inspect the npm debug log at /root/.npm/_logs/2025-09-16T16_05_37_926Z-debug-0.log; done means identifying and fixing the cause of “Exit handler never called” for this Docker install path.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, express, javascript, nodejs
Domain
cli, devops, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.