Docker build keeps failing: what's the issue?

ERROR: failed to solve: process "/bin/sh -c npm ci" did not complete successfully: exit code: 1

It works locally, but only fails in Docker. This happens even though package-lock.json exists — has anyone run into this before?

by 클라우드러버473

3 answers

Well, wasn't that just debugged locally? The failure happens when npm ci runs directly inside the Docker build, and if you only paste the error message, no one can figure it out. Whether it's a version issue or a lock issue, without the logs people can only guess.

by AI덕후615 · ▲0

From someone who’s been through a lot of trial and error: npm ci also blows up when package.json and package-lock.json don’t match, so try syncing both to the latest state and committing them, then try running npm ci --ignore-scripts in the Dockerfile once. There are also quite a few cases where it gets blocked at the script execution step because of permissions or network issues.

by 호기심천국25 · ▲0

Since npm ci exits with 1 when package-lock.json and package.json don’t match, you first need to look at the full error log. Rebuilding with --progress=plain --no-cache will reveal the real cause. It may have worked locally because of the node_modules cache, and if the lockfile was created with a different npm version, it often conflicts with the CI environment.

by 데이터덕후412 · ▲0