Dockerfile Error: Cannot find module '/app/packages/lib/node_modules/typescript/bin/tsc' #9363
Unanswered
Nubebuster
asked this question in
Help
Replies: 1 comment
-
|
Using RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -rWith a .gitignore at root specifying
And having typescript as a ROOT dev dependency works. Results in a working setup. Resulting working setup: FROM node:22-alpine AS base
# install pnpm
RUN wget -qO /bin/pnpm "https://github.com/pnpm/pnpm/releases/latest/download/pnpm-linuxstatic-x64" && chmod +x /bin/pnpm
# Configure pnpm global
ENV PNPM_HOME=/pnpm
ENV PATH=$PATH:$PNPM_HOME
RUN corepack enable
RUN pnpm add -g turbo
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
COPY ./ .
RUN turbo prune web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update && apk add --no-cache libc6-compat
WORKDIR /app
# First install dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml /app/pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml /app/pnpm-workspace.yaml
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -r
# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
RUN pnpm build --filter=web...
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD node apps/web/server.jsI hope someone scouring the internet having the same problem can use this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I have this dockerfile
But no matter what I do I end up with "Error: Cannot find module '/app/packages/lib/node_modules/typescript/bin/tsc'"
in the build step.
typescript indeed does not seem to be in the node_modules
Additional information
The build works fine if I do it on my computer
packages/lib/package.json has a dev dependency for typescript and the build script does
I've also tried many variations of the install such as
Beta Was this translation helpful? Give feedback.
All reactions