Skip to content

Remove explicit npm@11 upgrade from Dockerfiles#34

Merged
asepindrak merged 2 commits into
mainfrom
copilot/remove-npm-install-version-11
Apr 2, 2026
Merged

Remove explicit npm@11 upgrade from Dockerfiles#34
asepindrak merged 2 commits into
mainfrom
copilot/remove-npm-install-version-11

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

RUN npm install -g npm@11 fails with MODULE_NOT_FOUND: promise-retry during npm's self-upgrade — an internal dependency issue with npm v11 bootstrapping itself from the base image's npm.

Changes

  • backend/Dockerfile: Remove RUN npm install -g npm@11 from the base stage
  • frontend/Dockerfile: Remove RUN npm install -g npm@11 from the base stage

Both node:22-slim and node:20-alpine already ship with a modern npm (v10.x) sufficient for all install and build steps.

Original prompt

Problem

Docker build fails on the RUN npm install -g npm@11 command with the following error:

npm error code MODULE_NOT_FOUND
npm error Cannot find module 'promise-retry'

The error occurs during the npm self-upgrade step in the Dockerfile base stage (line 21).

Root Cause

npm v11 installation is missing internal dependencies (like promise-retry) required for the upgrade process. This is likely due to compatibility issues with npm v11 in the current node:22-slim Docker image.

Solution

Remove the explicit npm v11 upgrade. The node:22-slim base image already includes a modern, stable version of npm that's suitable for the build process. Removing this step:

  • Eliminates the MODULE_NOT_FOUND error
  • Uses npm version included in node:22-slim (which is typically npm v10.x)
  • Simplifies the Dockerfile and reduces build time
  • Maintains compatibility with all project dependencies

Changes

  • Remove line 21: RUN npm install -g npm@11

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: ada error ketika build di server

#10 [base 4/6] RUN npm install -g npm@11
#10 156.2 npm error code MODULE_NOT_FOUND
#10 156.2 npm error Cannot find module 'promise-retry'
#10 156.2 npm error Require stack:
#10 156.2 npm error - /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/index.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/node_modules/libnpmfund/lib/index.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/lib/utils/reify-output.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/lib/utils/reify-finish.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/lib/commands/install.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/lib/npm.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/lib/cli/entry.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/lib/cli.js
#10 156.2 npm error - /usr/local/lib/node_modules/npm/bin/npm-cli.js
#10 156.2 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-04-02T16_52_30_788Z-debug-0.log
#10 ERROR: process "/bin/sh -c npm install -g npm@11" did not complete successfully: exit code: 1

[base 4/6] RUN npm install -g npm@11:
156.2 npm error - /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/index.js
156.2 npm error - /usr/local/lib/node_modules/npm/node_modules/libnpmfund/lib/index.js
156.2 npm error - /usr/local/lib/node_modules/npm/lib/utils/reify-output.js
156.2 npm error - /usr/local/lib/node_modules/npm/lib/utils/reify-finish.js
156.2 npm error - /usr/local/lib/node_modules/npm/lib/commands/install.js
156.2 npm error - /usr/local/lib/node_modules/npm/lib/npm.js
156.2 npm error - /usr/local/lib/node_modules/npm/lib/cli/entry.js
156.2 npm error - /usr/local/lib/node_modules/npm/lib/cli.js
156.2 npm error - /usr/local/lib/node_modules/npm/bin/npm-cli.js
156.2 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-04-02T16_52_30_788Z-debug-0.log


Dockerfile:21

|
| # Update npm versi terbaru
| >>> RUN npm install -g npm@11
|
| # Salin dependency info lebih dulu

ERROR: failed to build: failed to solve: process "/bin/sh -c npm install -g npm@11" did not complete successfully: exit code: 1
❌ Docker build failed
Error occurred ❌, check the logs for details.

Assistant: I'll look at your Dockerfile to understand the build issue.

Assistant: Masalahnya ada pada baris 21: RUN npm install -g npm@11

Error menunjukkan bahwa npm versi 11 yang sedang diinstall tidak bisa menemukan module promise-retry. Ini adalah masalah kompatibilitas atau dependency yang hilang saat npm sedang self-upgrading.

Solusi yang Disarankan:

Opsi 1: Hapus/Skip npm upgrade (Paling aman)

  • Node 22-slim sudah dilengkapi dengan npm yang cukup baru
  • Coba hapus baris tersebut dan gunakan npm default yang sudah ada

Opsi 2: Upgrade npm dengan cara yang lebih aman

RUN npm install -g npm@latest --no-save

atau

RUN npm install -g npm@10

Opsi 3: Perbaiki npm upgrade dengan dependency yang tepat

RUN npm install -g npm@11 --force

Penyebab Utama:

Ketika npm sedang upgrade ke versi 11, ada dependency internal yang hilang (promise-retry). Ini bisa terjadi karena:

  1. NPM v11 belum stable sepenuhnya di repository
  2. Docker image base (node:22-slim) mungkin punya state npm yang corrupt

Apa yang ingin kamu lakukan?

  1. Hapus npm upgrade (recommended - Node 22 sudah punya npm yang baik)
  2. Gunakan npm versi yang lebih stabil (v10 atau latest)
  3. Tambahkan --force flag ke npm upgrade

Apakah kamu ingin aku buat PR untuk memperbaiki Dockerfile?

User: boleh buatkan aja langsung PR nya

...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Remove npm v11 upgrade from Dockerfile Remove explicit npm@11 upgrade from Dockerfiles Apr 2, 2026
Copilot AI requested a review from asepindrak April 2, 2026 17:11
@asepindrak asepindrak marked this pull request as ready for review April 2, 2026 17:17
Copilot AI review requested due to automatic review settings April 2, 2026 17:17
@asepindrak asepindrak merged commit 4362883 into main Apr 2, 2026
3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the explicit global upgrade to npm@11 from the backend and frontend Docker build base stages to avoid the MODULE_NOT_FOUND: promise-retry failure during npm self-upgrade, relying instead on the npm version bundled with the Node base images.

Changes:

  • Removed RUN npm install -g npm@11 from backend/Dockerfile base stage.
  • Removed RUN npm install -g npm@11 from frontend/Dockerfile base stage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backend/Dockerfile Drops npm v11 self-upgrade step to prevent Docker build failure in the base stage.
frontend/Dockerfile Drops npm v11 self-upgrade step to prevent Docker build failure in the base stage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants