Output Directory Content Deletion in Dev Mode
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
Nitro Version: 2.10.4
Node Version: v20.18.0
Package Manager: pnpm@9.12.3
Operating System: Linux
Reproduction
Steps to Reproduce
- Create a new Nuxt 3.14.x project (which uses Nitro 2.10.4)
- Run production build:
pnpm build - Verify output directory structure:
.output/
├── nitro.json
├── public/
│ ├── _nuxt/
│ ├── favicon.ico
│ └── robots.txt
└── server/
├── chunks/
├── index.mjs
└── node_modules/
- Start development server:
pnpm dev - Observe output directory is minimized to:
.output/
├── public/
└── server/
├── index.mjs
└── index.mjs.map
Expected Behavior
- Production build output should remain intact when starting development server
- Development server should not interfere with production build artifacts
Current Behavior
- Starting development server deletes most of the production build output
- Only minimal server files remain in the output directory
Workaround
We found a temporary workaround by separating development and production output directories:
{
output: {
dir: process.env.NODE_ENV === "development" ? ".output-dev" : ".output",
serverDir: process.env.NODE_ENV === "development"
? ".output-dev/server"
: ".output/server",
publicDir: process.env.NODE_ENV === "development"
? ".output-dev/public"
: ".output/public"
}
}
Describe the bug
When using Nitro (via Nuxt 3.14.x), the production build output directory content is unexpectedly deleted or minimized when starting the development server. This issue was identified after observing the behavior in Nuxt 3.14.x and was traced back to Nitro's handling of the output directory.
However, this is suboptimal as:
- Development environment shouldn't need to affect production build output
- Creating a separate output directory for development seems unnecessary
- This behavior changed between Nitro versions (works correctly in older versions)
Technical Details
- The issue seems related to Nitro's handling of the output directory during development mode
- The problem appeared with Nuxt 3.14.x which uses Nitro 2.10.x
- The issue does not occur with Nuxt 3.13.2 (older Nitro version)
Questions
- Is this an intended change in behavior?
- Is there a proper way to preserve production build output while running development server?
- Should we consider adding a configuration option to prevent development mode from cleaning production build files?
Additional context
No response
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with a Nuxt 3.14.x project using Nitro 2.10.4: run pnpm build, inspect .output/, then run pnpm dev and compare the contents. Trace Nitro's development-mode output-directory handling and verify that starting development preserves production artifacts without requiring separate directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, nuxt, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100