nextjs - ✅(Solved) Fix Standalone build output path includes workspace package name in Next.js 15.5.0+ with pnpm workspace [2 pull requests, 7 comments, 6 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#84257Fetched 2026-04-08 02:20:11
View on GitHub
Comments
7
Participants
6
Timeline
21
Reactions
7
Author
Timeline (top)
subscribed ×8commented ×7cross-referenced ×2mentioned ×2

Fix Action

Fix / Workaround

The issue causes the standalone build to include the package name in the output path structure, which breaks existing deployment configurations and scripts that expect the standard .next/standalone/server.js path. This is particularly problematic for Docker deployments and CI/CD pipelines that rely on the predictable standalone output structure. Workaround: Currently, users need to update their deployment scripts to account for the package name being included in the path, or modify their package.json name to avoid this issue. Impact: This affects any project using standalone mode with pnpm workspaces, requiring changes to deployment configurations and potentially breaking existing Docker images and deployment scripts.

PR fix notes

PR #84339: fix: remove package name from standalone build output paths

Description (problem / solution / changelog)

What?

Fixed standalone build output paths to exclude workspace package names when using pnpm workspaces.

Why?

In Next.js 15.5.0+, when using output: 'standalone' with pnpm workspaces, the server.js file was incorrectly placed at .next/standalone/{package_name}/server.js instead of the expected .next/standalone/server.js. This broke existing deployment scripts and Docker configurations that expect the standard location.

How?

Modified the path calculation logic in two files:

  • packages/next/src/build/utils.ts: Fixed server.js and package.json paths in copyTracedFiles function

  • packages/next/src/build/index.ts: Fixed server.js path in writeStandaloneDirectory function and removed package name from middleware, pages, and app directory paths

  • The fix ensures core server files are placed directly in the standalone directory while preserving directory structure for other files.

Related Issues

  • fixes: #84257

Changed files

  • packages/next/src/build/index.ts (modified, +2/-4)
  • packages/next/src/build/utils.ts (modified, +7/-11)

PR #60: feat: Web Dashboard Shell (Next.js 16, Tailwind v4, Discord OAuth2)

Description (problem / solution / changelog)

Summary

Adds the foundation for the bills-bot web dashboard — a Next.js app with Discord OAuth2 authentication, responsive layout, and server management capabilities.

Closes #28

What's Included

Stack

  • Next.js 16.1.6 with React 19, TypeScript, Turbopack
  • Tailwind CSS v4 with CSS-based config (@theme block, no tailwind.config)
  • Shadcn UI components (button, card, avatar, dropdown, sheet, separator)
  • NextAuth.js 4 with Discord OAuth2 provider

Features

  • Discord OAuth2 — JWT sessions with access token, user ID, refresh token
  • Protected routes — Dashboard routes protected via Next.js proxy (middleware)
  • Server selector — Dropdown filtering to guilds where both user and bot are present
  • Responsive layout — Sidebar for desktop, hamburger sheet menu for mobile
  • Landing page — Bot features showcase + "Add to Server" button
  • Login page — Discord sign-in with auto-redirect if already authenticated
  • Dashboard overview — Placeholder stats cards + getting started guide
  • API route/api/guilds fetches mutual guilds (user ∩ bot)

Infrastructure

  • pnpm workspace setup (web/ as workspace member)
  • Dockerfile with multi-stage build (deps → builder → runner with standalone output)
  • Railway config (railway.toml with health check)
  • Environment config.env.example and .env.local.example

Testing

  • 56 tests across 13 test files
  • Coverage: 92% statements, 81% branches, 87% functions, 92% lines
  • Tests cover: auth, discord utils, API routes, all pages, all layout components, proxy config

Key Files

PathDescription
web/package.jsonDependencies and scripts
web/src/app/page.tsxLanding page
web/src/app/login/page.tsxDiscord login
web/src/app/dashboard/Protected dashboard pages
web/src/components/layout/Shell, sidebar, header, server selector
web/src/lib/auth.tsNextAuth config with Discord provider
web/src/lib/discord.tsDiscord API helpers (guilds, avatars)
web/src/proxy.tsRoute protection (Next.js 16 proxy)
pnpm-workspace.yamlMonorepo workspace config

Environment Variables

DISCORD_CLIENT_ID        # Discord OAuth2 app client ID
DISCORD_CLIENT_SECRET    # Discord OAuth2 app client secret  
NEXTAUTH_SECRET          # JWT signing secret
NEXTAUTH_URL             # Canonical site URL
BOT_API_URL              # Bot API endpoint for guild list
NEXT_PUBLIC_DISCORD_CLIENT_ID  # Public client ID for invite links

How to Test

cd web
pnpm install
pnpm build    # Verify production build
pnpm lint     # TypeScript check
pnpm test     # Run all 56 tests
pnpm dev      # Start dev server (needs .env.local)

Changed files

  • .gitignore (modified, +6/-0)
  • README.md (modified, +51/-0)
  • package.json (modified, +3/-3)
  • pnpm-lock.yaml (modified, +2746/-83)
  • pnpm-workspace.yaml (added, +2/-0)
  • web/.env.example (added, +22/-0)
  • web/.env.local.example (added, +11/-0)
  • web/Dockerfile (added, +63/-0)
  • web/components.json (added, +20/-0)
  • web/next-env.d.ts (added, +6/-0)
  • web/next.config.ts (added, +46/-0)
  • web/package.json (added, +46/-0)
  • web/postcss.config.mjs (added, +7/-0)
  • web/public/.gitkeep (added, +0/-0)
  • web/src/app/api/auth/[...nextauth]/route.ts (added, +6/-0)
  • web/src/app/api/guilds/route.ts (added, +38/-0)
  • web/src/app/api/health/route.ts (added, +9/-0)
  • web/src/app/dashboard/error.tsx (added, +36/-0)
  • web/src/app/dashboard/layout.tsx (added, +19/-0)
  • web/src/app/dashboard/page.tsx (added, +90/-0)
  • web/src/app/error.tsx (added, +29/-0)
  • web/src/app/global-error.tsx (added, +57/-0)
  • web/src/app/globals.css (added, +102/-0)
  • web/src/app/layout.tsx (added, +26/-0)
  • web/src/app/login/page.tsx (added, +99/-0)
  • web/src/app/page.tsx (added, +187/-0)
  • web/src/components/error-card.tsx (added, +37/-0)
  • web/src/components/layout/dashboard-shell.tsx (added, +33/-0)
  • web/src/components/layout/header.tsx (added, +108/-0)
  • web/src/components/layout/mobile-sidebar.tsx (added, +42/-0)
  • web/src/components/layout/server-selector.tsx (added, +211/-0)
  • web/src/components/layout/sidebar.tsx (added, +92/-0)
  • web/src/components/providers.tsx (added, +13/-0)
  • web/src/components/ui/avatar.tsx (added, +49/-0)
  • web/src/components/ui/button.tsx (added, +58/-0)
  • web/src/components/ui/card.tsx (added, +82/-0)
  • web/src/components/ui/dropdown-menu.tsx (added, +87/-0)
  • web/src/components/ui/separator.tsx (added, +30/-0)
  • web/src/components/ui/sheet.tsx (added, +121/-0)
  • web/src/components/ui/skeleton.tsx (added, +12/-0)
  • web/src/lib/auth.ts (added, +178/-0)
  • web/src/lib/discord.server.ts (added, +235/-0)
  • web/src/lib/discord.ts (added, +41/-0)
  • web/src/lib/logger.ts (added, +24/-0)
  • web/src/lib/utils.ts (added, +6/-0)
  • web/src/proxy.ts (added, +28/-0)
  • web/src/types/discord.ts (added, +18/-0)
  • web/src/types/next-auth.d.ts (added, +21/-0)
  • web/tests/__mocks__/server-only.ts (added, +2/-0)
  • web/tests/api/guilds.test.ts (added, +127/-0)
  • web/tests/api/health.test.ts (added, +13/-0)
  • web/tests/app/dashboard.test.tsx (added, +85/-0)
  • web/tests/app/landing.test.tsx (added, +60/-0)
  • web/tests/app/login.test.tsx (added, +107/-0)
  • web/tests/components/layout/dashboard-shell.test.tsx (added, +39/-0)
  • web/tests/components/layout/header.test.tsx (added, +138/-0)
  • web/tests/components/layout/server-selector.test.tsx (added, +123/-0)
  • web/tests/components/layout/sidebar.test.tsx (added, +37/-0)
  • web/tests/components/providers.test.tsx (added, +25/-0)
  • web/tests/lib/auth.test.ts (added, +301/-0)
  • web/tests/lib/discord.test.ts (added, +533/-0)
  • web/tests/lib/utils.test.ts (added, +24/-0)
  • web/tests/middleware.test.ts (added, +113/-0)
  • web/tests/setup.ts (added, +7/-0)
  • web/tsconfig.json (added, +41/-0)
  • web/vitest.config.ts (added, +35/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0
Binaries:
  Node: 22.13.0
  pnpm: 10.15.1
Relevant Packages:
  next: 15.5.3
  typescript: 5.9.2
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/mikan3rd/nextjs-workspace-bug-reproduction

To Reproduce

  1. Create a pnpm workspace with a Next.js application (e.g., "main_app")
  2. Configure the Next.js app with output: 'standalone' in next.config.ts
  3. Run next build in "main_app" directory
  4. Check the generated standalone output directory

Current vs. Expected behavior

Current behavior: The standalone build creates the server.js file at .next/standalone/main_app/server.js This breaks existing deployment scripts and Docker configurations that expect the server.js file to be at the standard location.

Expected behavior: The standalone build should create the server.js file at .next/standalone/server.js as it did in previous versions

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0
Binaries:
  Node: 22.13.0
  pnpm: 10.15.1
Relevant Packages:
  next: 15.5.3
  typescript: 5.9.2
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Output

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

This issue appears to be introduced in Next.js 15.5.0 and affects projects using:

  • output: "standalone" configuration
  • pnpm workspace environment

The issue causes the standalone build to include the package name in the output path structure, which breaks existing deployment configurations and scripts that expect the standard .next/standalone/server.js path. This is particularly problematic for Docker deployments and CI/CD pipelines that rely on the predictable standalone output structure. Workaround: Currently, users need to update their deployment scripts to account for the package name being included in the path, or modify their package.json name to avoid this issue. Impact: This affects any project using standalone mode with pnpm workspaces, requiring changes to deployment configurations and potentially breaking existing Docker images and deployment scripts.

extent analysis

TL;DR

Update deployment scripts to account for the package name being included in the standalone output path or modify the package.json name to avoid this issue.

Guidance

  • Verify the issue by checking the generated standalone output directory after running next build in the "main_app" directory.
  • Check the next.config.ts file to ensure the output property is set to 'standalone'.
  • Consider modifying the package.json name to avoid the issue, if possible.
  • Update deployment scripts to account for the new path structure, which includes the package name.

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

This issue appears to be specific to Next.js version 15.5.0 and later, and only affects projects using the output: "standalone" configuration with pnpm workspaces.

Recommendation

Apply workaround: Update deployment scripts to account for the package name being included in the path, as this is the most straightforward solution to mitigate the issue until a fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING