next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Standalone build output path includes workspace package name in Next.js 15.5.0+ with pnpm workspace

Open mikan3rd opened this issue 3 months ago • 3 comments

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.

mikan3rd avatar Sep 26 '25 03:09 mikan3rd

@mikan3rd hey, fixed the standalone build path problem server.js now correctly goes to .next/standalone/server.js instead of including the workspace package name in the path

let me know

naaa760 avatar Sep 29 '25 12:09 naaa760

@naaa760 Thank you for creating the pull request with your fixes! I'm looking forward to seeing your fixes merged.

mikan3rd avatar Oct 03 '25 05:10 mikan3rd

Any update on this?

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

gregpavl avatar Dec 09 '25 17:12 gregpavl