Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

590
Visualizações
PNPM linking with standalone NextJS build

I'm trying to create production Dockerfile using NextJS standalone mode and PNPM.

In next.config.js i have output configuration:

  experimental: {
    outputStandalone: true,
    outputFileTracingRoot: path.join(__dirname, '../../'),
  },

And in Dockerfile I'm using multi-stage build:

# BUILD STEP
FROM node:16.13-alpine as landing-builder
WORKDIR /dml-sdk

COPY ./pnpm-workspace.yaml .
COPY ./pnpm-lock.yaml .
COPY ./tsconfig.base.json .
COPY ./package.json .

COPY ./apps/landing ./apps/landing

RUN apk --no-cache add curl
RUN apk --no-cache add git
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
RUN pnpm config set store-dir .pnpm-store

RUN pnpm i
RUN pnpm build

# RUNNER STEP
FROM node:16.13-alpine as landing-runner
WORKDIR /dml-sdk

ENV NODE_ENV production

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001

COPY --from=landing-builder /dml-sdk/apps/landing/public ./public
COPY --from=landing-builder --chown=nextjs:nodejs /dml-sdk/apps/landing/.next/standalone ./
COPY --from=landing-builder --chown=nextjs:nodejs /dml-sdk/node_modules ./node_modules

ENV NEXT_TELEMETRY_DISABLED 1
ENV PORT 3010

EXPOSE 3010

WORKDIR /dml-sdk/apps/landing

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

For some reason I'm running into error:

landing    | Error: Cannot find module 'next/dist/server/next-server'
landing    | Require stack:
landing    | - /powerplay-sdk/apps/landing/server.js

Looks like the next-server is not bundled in standalone directory, and line:

const NextServer = require('next/dist/server/next-server').default

is linked to root node_modules, instead of /dml-sdk/standalone/apps/landing/node_modules:

node_modules/.pnpm/next@12.0.8_react-dom@17.0.2+react@17.0.2/node_modules/next/dist/server/next-server.d.ts

Is it possible to disable next-server link in BUILD step, so that standalone node_modules would include next-server?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda