Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No routeModule available to create server routes #13148

Open
AlemTuzlak opened this issue Mar 3, 2025 · 1 comment
Open

No routeModule available to create server routes #13148

AlemTuzlak opened this issue Mar 3, 2025 · 1 comment
Labels

Comments

@AlemTuzlak
Copy link
Contributor

I'm using React Router as a...

framework

Reproduction

Not provided unfortunately

System Info

Fly.io/github actions

Used Package Manager

pnpm

Expected Behavior

Works without crashing

Actual Behavior

So we have a super frustrating issue on our website that has been happening since v2.15 of remix and now since v7.0.0 release of react-router. After a few days/weeks/months on random machines we get the following error mesage:

Error: No `routeModule` available to create server routes
 
invariant2(react-router.dist.development:chunk-D52XG6IA)

which crashes our website and results in an unhandled "Unexpected server error" shown. This happens because the error happens inside of react-router itself:
Image
Here is the stack trace from sentry:

Image
Here is our dockerfile:

# syntax = docker/dockerfile:1.4

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-slim as base

# Remix/Prisma app lives here
WORKDIR /app

# Throw-away build stage to reduce size of final image
FROM base as build
ARG PNPM_VERSION=9.7.0
RUN npm install -g pnpm@$PNPM_VERSION

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y \
        build-essential \
        node-gyp \
        openssl \
        pkg-config \
        python-is-python3 \
        ca-certificates \
        fuse3 \
        sqlite3 \
        curl && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install node modules
COPY --link pnpm-lock.yaml package.json ./
RUN pnpm install --prefer-offline --prod=false

# Generate Prisma Client
COPY --link prisma .
RUN pnpm run prisma:generate

# Copy application code
COPY --link . .
 
# Set production environment
ENV NODE_ENV="production"

RUN pnpm run build

# Remove development dependencies
RUN pnpm prune --prod

FROM build as runner
# Copy built application
COPY --from=build /app /app 

EXPOSE ${PORT}

CMD ["pnpm", "run", "start"]

We are not sure why this would happen and we've also noticed that the stack trace includes the development distribution of react-router, I'm guessing this could be the cause of it?

If you need additional info let me know

@AlemTuzlak AlemTuzlak added the bug label Mar 3, 2025
@GabenGar
Copy link

GabenGar commented Mar 3, 2025

React router only exports development modules, that's why you see it in the stack.
Presumably it is a temporary solution, but most likely unrelated to your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants