N
Nuxt2mo ago
Lju

Running `npx nuxi dev` will empty my `.output/public` folder

After I build production with npx nuxi build my .output/public gets filled with my production data. But whenever I run npx nuxi dev and open the dev web, the public folder of .output gets emptied.
root@Ubuntu # ls -la .output/public
total 52
drwxr-xr-x 4 root root 4096 Jan 27 21:00 .
drwxr-xr-x 4 root root 4096 Jan 27 21:00 ..
-rw-r--r-- 1 root root 652 Jan 27 21:00 favicon-16x16.png
-rw-r--r-- 1 root root 1216 Jan 27 21:00 favicon-32x32.png
-rw-r--r-- 1 root root 15086 Jan 27 21:00 favicon.ico
drwxr-xr-x 2 root root 12288 Jan 27 21:00 _fonts
drwxr-xr-x 3 root root 4096 Jan 27 21:00 _nuxt
-rw-r--r-- 1 root root 1 Jan 27 21:00 robots.txt

root@Ubuntu # npx nuxi dev
> npx nuxi dev

Nuxt 3.15.2 with Nitro 2.10.4 nuxi 9:02:31 PM
9:02:32 PM

➜ Network: http://XXX.XXX.XXX.XXX:3002/ [QR code]

➜ DevTools: press Shift + Alt + D in the browser (v1.7.0) 9:02:33 PM

✔ Vite client built in 31ms 9:02:34 PM
✔ Vite server built in 591ms 9:02:35 PM
✔ Nuxt Nitro server built in 697 ms nitro 9:02:36 PM
ℹ Vite client warmed up in 128ms 9:02:36 PM
ℹ Vite server warmed up in 1038ms 9:02:37 PM
^C
root@Ubuntu # ls -la .output/public
total 8
drwxr-xr-x 2 root root 4096 Jan 27 21:02 .
drwxr-xr-x 3 root root 4096 Jan 27 21:02 ..
root@Ubuntu # ls -la .output/public
total 52
drwxr-xr-x 4 root root 4096 Jan 27 21:00 .
drwxr-xr-x 4 root root 4096 Jan 27 21:00 ..
-rw-r--r-- 1 root root 652 Jan 27 21:00 favicon-16x16.png
-rw-r--r-- 1 root root 1216 Jan 27 21:00 favicon-32x32.png
-rw-r--r-- 1 root root 15086 Jan 27 21:00 favicon.ico
drwxr-xr-x 2 root root 12288 Jan 27 21:00 _fonts
drwxr-xr-x 3 root root 4096 Jan 27 21:00 _nuxt
-rw-r--r-- 1 root root 1 Jan 27 21:00 robots.txt

root@Ubuntu # npx nuxi dev
> npx nuxi dev

Nuxt 3.15.2 with Nitro 2.10.4 nuxi 9:02:31 PM
9:02:32 PM

➜ Network: http://XXX.XXX.XXX.XXX:3002/ [QR code]

➜ DevTools: press Shift + Alt + D in the browser (v1.7.0) 9:02:33 PM

✔ Vite client built in 31ms 9:02:34 PM
✔ Vite server built in 591ms 9:02:35 PM
✔ Nuxt Nitro server built in 697 ms nitro 9:02:36 PM
ℹ Vite client warmed up in 128ms 9:02:36 PM
ℹ Vite server warmed up in 1038ms 9:02:37 PM
^C
root@Ubuntu # ls -la .output/public
total 8
drwxr-xr-x 2 root root 4096 Jan 27 21:02 .
drwxr-xr-x 3 root root 4096 Jan 27 21:02 ..
5 Replies
kapa.ai
kapa.ai2mo ago
Hi @Lju. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This behavior you're experiencing is actually expected and by design in Nuxt 3. Let me explain why this happens and provide some context: 1. The .output folder is generated when you run nuxt build for production builds. As stated in the Nuxt documentation on the .output directory, this directory is created when building your application for production. 2. When you run nuxi dev, Nuxt starts a development server. This development server doesn't use the .output folder. Instead, it serves your application directly from memory and the source files in your project. 3. The development server is designed to provide fast refresh and hot module replacement features, which wouldn't be possible if it was serving from the static .output folder. 4. As mentioned in the Nuxt documentation on the nuxi dev command, this command starts a development server with hot module replacement. 5. The emptying of the .output/public folder when running nuxi dev is likely a side effect of Nuxt preparing the environment for development. It's not using this folder in development mode, so it clears it to avoid any potential conflicts or outdated files. If you need to keep the production build output while running the development server, you might consider renaming or moving the .output folder before starting the dev server. However, keep in mind that the development server won't use this folder anyway. For deployment and production use, you should always use the output generated by nuxt build. The development server is strictly for development purposes and should not be used in a production environment. Nuxt documentation on the .output directory recommends adding the .output directory to your .gitignore file to avoid pushing the build output to your repository, as it should be regenerated on each production build. </instructions> ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@152910716171452416> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Lju
LjuOP2mo ago
@kapa.ai as stated by you, nuxi dev should never write or change .output but in-fact it does. This might be a bug, since this behavior wasn't happening in older versions.
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're right, and I apologize for my previous misstatement. You've correctly pointed out that nuxi dev should not be modifying the .output directory, and if it is doing so, this could indeed be a bug. Let's look into this further based on the information we have: 1. According to the Nuxt documentation on the .output directory, the .output directory is created when building your application for production, and you should not touch any files inside since the whole directory will be re-created when running nuxt build. 2. The Nuxt documentation on the .nuxt directory states that the .nuxt directory is used in development, not the .output directory. This further supports that nuxi dev should not be modifying .output. 3. There's evidence of a similar issue being reported and fixed in a GitHub pull request: fix(nuxt): empty nitro buildDir in dev mode. This PR mentions that there was an issue with the dev server reusing the previous dev server build, which could cause weird behavior. Given this information, it appears that the behavior you're experiencing - nuxi dev emptying the .output/public folder - is indeed unexpected and likely a bug, especially if this is a new behavior that wasn't present in older versions. To address this issue, I would recommend the following steps: 1. Check your Nuxt version and update to the latest version if you haven't already, as the issue might have been fixed in a recent release. 2. If the problem persists after updating, it would be valuable to report this as a bug to the Nuxt team. You can do this by creating an issue on the Nuxt GitHub repository. 3. When reporting the bug, make sure to follow the guidelines in the Nuxt documentation on reporting bugs, including creating a minimal reproduction of the issue. 4. In the meantime, as a workaround, you might want to consider backing up your .output directory before running nuxi dev if you need to preserve its contents. Thank you for bringing this to attention. It's through community feedback like yours that such issues can be identified and resolved. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@152910716171452416> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?