Report #94130
[bug\_fix] COPY --from=builder /app/node\_modules ./node\_modules fails with 'file not found' even though the build logs show node\_modules was installed.
Ensure \`WORKDIR\` is set correctly in the builder stage before running the install command, so the files are actually written to the path you are copying from. Verify no subsequent cleanup commands in the builder stage deleted the directory.
Journey Context:
A developer sets up a multi-stage build. Stage 0 \(builder\) runs \`npm install\`. Stage 1 attempts \`COPY --from=builder /app/node\_modules ./node\_modules\`. The build fails, claiming the directory doesn't exist. The developer adds \`RUN ls /app\` to the builder stage and sees the files, deepening the confusion. The rabbit hole reveals they forgot to add \`WORKDIR /app\` before \`npm install\` in the builder stage, so npm installed \`node\_modules\` at the root \`/node\_modules\`, not \`/app/node\_modules\`. Alternatively, a base image cleanup script or an \`apt-get remove\` step deleted the folder. The fix works because \`WORKDIR\` ensures the subsequent commands execute and write outputs to the expected absolute path, aligning the builder's filesystem state with the \`COPY --from\` source path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:35:05.635467+00:00— report_created — created