Skip to content

Components.bundle.js returns 500 despite successful @adminjs/bundler execution #1777

Open

Description

@leonardomarchioro

I'm using AdminJS with a custom componentLoader and custom components. I'm following the official bundling instructions, including @adminjs/bundler, to serve AdminJS in a Docker environment without write access to .adminjs.

However, when trying to access http://localhost:3000/admin/frontend/assets/components.bundle.js, the request fails with a 500 Internal Server Error, even though the bundling script completes successfully and the file exists.

What I’ve Done
Added @adminjs/bundler

Created bundle-admin.ts:

import { bundle } from '@adminjs/bundler';
import { componentLoader } from "./components/index.js";

(async () => {
  await bundle({
    componentLoader,
    destinationDir: 'public',
  });
})();

Script runs correctly: yarn admin:bundle (also confirmed during Docker build phase)

Files such as components.bundle.js are generated inside public/

Added static middleware to app.ts:

this.app.use(express.static(path.join(process.cwd(), 'public')));
Confirmed that the file exists inside the Docker container

The Problem
Even with the file present and being served via express.static, trying to load:

http://localhost:3000/admin/frontend/assets/components.bundle.js
Results in:

500 Internal Server Error
No visible logs are printed that would help pinpoint the failure.

🧾 Project Details
Directory structure inside Docker container:

/app
├── dist
│   └── admin
│       ├── admin.js
│       ├── components
│       ├── bundle-admin.js
├── public
│   ├── components.bundle.js ✅
├── node_modules
├── prisma
├── package.json
└── yarn.lock

Dockerfile:

FROM node:18-alpine AS builder

WORKDIR /app

COPY package.json yarn.lock ./
COPY tsconfig.json ./
COPY prisma ./prisma
COPY src ./src

RUN yarn install --frozen-lockfile
RUN yarn prisma generate
RUN yarn build

FROM node:18-alpine AS runner

WORKDIR /app

COPY --from=builder /app/package.json ./
COPY --from=builder /app/yarn.lock ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma

ENV NODE_ENV=production

RUN yarn admin:bundle

EXPOSE 3000

CMD ["node", "dist/server.js"]

Versions

adminjs: ^7.8.16
@adminjs/express: ^6.1.1
@adminjs/prisma: ^5.0.4
@adminjs/bundler: ^3.0.0
@adminjs/themes: ^1.0.1
express: ^5.1.0
node: 18 (alpine)
typescript: ^5.8.3

Expected Behavior
Bundled assets such as components.bundle.js should be served successfully from the /public directory via express.static.

Questions
Is AdminJS expecting the bundle at a different path internally?

Is there an internal handler that's trying to resolve and serve components.bundle.js differently?

Do I need to register the static route before AdminJS middleware?

Any guidance or examples would be appreciated 🙏

Activity

  1. dziraf commented on Jul 30, 2025

    @dziraf
    Contributor

    If you place your assets in public dir and serve them via static middleware, you must also set assetsCDN in your AdminJS config:
    https://docs.adminjs.co/installation/migration-guide-v7#adminjs-bundler

    Make sure that besides components.bundle.js you also move other bundle files into public directory.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions