Skip to content

[BUG] EAI_AGAIN from Dockerfile #8247

@AlanGRutter

Description

@AlanGRutter

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

I have an Angular project that I am deploying to Azure using Dockerfile. Everything worked fine up until last week, and then npm starting failing with 'Exit handler never called!'. I have researched this extensively over the weekend and tried clearing cache, package-lock.json, changing to http instead https registry.

I am running Ubuntu 22 on an Amazon Workspace. I keep getting EAI_AGAIN errors from multiple packages and retries fail to fix the issue.

dockerfile.log

My dockerfile is :

#############################
# 1️⃣ Base image for building
#############################
FROM node:23-alpine AS base

RUN npm install -g @angular/cli

# Set the working directory
WORKDIR /app

# Build args
ARG PROJECT=""
ARG BUILDCMD="build"

# Copy package.json and package-lock.json files
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm npm install --legacy-peer-deps --force --verbose

# Copy all files
COPY . .

# Build the application
RUN npm run ${BUILDCMD} -- ${PROJECT}

##################################
# 2️⃣ Final image: Serve with Nginx
##################################
FROM nginx:stable-alpine AS final

# Copy the custom nginx template
COPY default.conf.template /etc/nginx/templates/default.conf.template

# Clean default Nginx files
RUN rm -rf /usr/share/nginx/html/*

# Use project name to locate correct dist output
ARG PROJECT=""
COPY --from=base /app/dist/${PROJECT}/browser /usr/share/nginx/html
# Replace the default nginx conf

COPY ./default.conf.template /etc/nginx/templates/default.conf.template

# Ensure correct file ownership
RUN chown -R nginx:nginx /usr/share/nginx/html

# Set appropriate permissions
RUN chmod -R 755 /usr/share/nginx/html

EXPOSE 80

# Render template and launch nginx
CMD ["nginx", "-g", "daemon off;"]

Expected Behavior

npm should install packages correctly and be able to complete the build.

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm:
  • Node.js:
  • OS Name:
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions