Unhandled Runtime Error ChunkLoadError

Hello, I am using Docker to launch a React container and the Dockerfile is as follows: FROM node:23-alpine # Create non-root user with configurable UID/GID ARG USER_ID=999 ARG GROUP_ID=995 RUN addgroup -g ${GROUP_ID} appuser && \ adduser -S -u ${USER_ID} -G appuser appuser WORKDIR /app COPY package*.json ./ # Install dependencies as root first RUN npm install -g npm@latest && \ npm install --legacy-peer-deps # Create .next directory with correct permissions RUN mkdir -p /app/.next && \ chown -R ${USER_ID}:${GROUP_ID} /app/.next COPY --chown=${USER_ID}:${GROUP_ID} . . # Ensure proper permissions for node_modules RUN chown -R ${USER_ID}:${GROUP_ID} /app/node_modules USER ${USER_ID} EXPOSE 3000 CMD ["npm", "run", "dev"] I get the following error when opening some pages: The website uses React as the frontend and Laravel as the backend. How to solve it? Thank you.

May 10, 2025 - 09:09
 0
Unhandled Runtime Error ChunkLoadError

Hello,
I am using Docker to launch a React container and the Dockerfile is as follows:

FROM node:23-alpine

# Create non-root user with configurable UID/GID
ARG USER_ID=999
ARG GROUP_ID=995

RUN addgroup -g ${GROUP_ID} appuser && \
    adduser -S -u ${USER_ID} -G appuser appuser

WORKDIR /app

COPY package*.json ./

# Install dependencies as root first
RUN npm install -g npm@latest && \
    npm install --legacy-peer-deps

# Create .next directory with correct permissions
RUN mkdir -p /app/.next && \
    chown -R ${USER_ID}:${GROUP_ID} /app/.next

COPY --chown=${USER_ID}:${GROUP_ID} . .

# Ensure proper permissions for node_modules
RUN chown -R ${USER_ID}:${GROUP_ID} /app/node_modules

USER ${USER_ID}

EXPOSE 3000

CMD ["npm", "run", "dev"]

I get the following error when opening some pages:

Image description

The website uses React as the frontend and Laravel as the backend.

How to solve it?

Thank you.