Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

587
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!