Next.js standalone output missing static and public files in CI
With output: 'standalone', next build produces a minimal .next/standalone server that does not include .next/static or public. If your image or artifact omits those, the server starts but assets 404 or the route fails.
What this error means
The standalone server runs but pages render unstyled, scripts 404, or images under /public are missing, because only .next/standalone was copied without .next/static and public.
next build
# Dockerfile copying only the standalone server
COPY --from=builder /app/.next/standalone ./
# missing: .next/static and public -> assets 404 at runtimeCommon causes
standalone intentionally excludes static and public
The standalone trace copies only server dependencies; .next/static and public are separate and must be added by you.
A Dockerfile or artifact copies only the server
A COPY that grabs .next/standalone alone leaves the browser assets behind.
How to fix it
Copy static and public alongside the server
- Copy
.next/standaloneas the app root. - Copy
.next/staticinto.next/staticof the standalone tree. - Copy
publicinto the standalone tree, then runnode server.js.
Dockerfile
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./publicEnable standalone output deliberately
Confirm the config opts in, so the standalone folder is produced.
next.config.js
// next.config.js
module.exports = { output: 'standalone' }How to prevent it
- Always copy
.next/staticandpublicwith the standalone server. - Test the produced image serves CSS, JS, and public assets.
- Keep the COPY steps in sync when the output mode changes.
Related guides
Next.js "ENOENT: no such file or directory, open '.next/...'" in CIFix Next.js "ENOENT: no such file or directory, open '.next/build-manifest.json'" in CI - a step expects buil…
Next.js "Image Optimization using the default loader ... requires sharp" in CIFix Next.js "Error: 'sharp' is required to be installed in standalone mode for the image optimization" in CI…
Next.js "Image Optimization ... not compatible with `next export`" in CIFix Next.js "Image Optimization using the default loader is not compatible with `output: export`" in CI - a s…