Next.js Discord

Discord Forum

Static Export - Not producing output file despite successful build.

Unanswered
English Spot posted this in #help-forum
Open in Discord
Avatar
English SpotOP
My next config is:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
distDir: "out",
images: {
unoptimized: true,
},
};


When I run npm run build I get:
Route (app) Size First Load JS
┌ ○ / 43.4 kB 142 kB
└ ○ /_not-found 875 B 88 kB
+ First Load JS shared by all 87.1 kB
├ chunks/23-93bd7f4baad7a8e2.js 31.6 kB
├ chunks/fd9d1056-360e5dd5b3902a99.js 53.7 kB
└ other shared chunks (total) 1.89 kB


○ (Static) prerendered as static content


Yet, it does not produce a folder with html/css/javascript files in the specific "out" directory. What's weird though is that when I run npm run start, my website will pop up. I thought that npm run start would be using the files from the build step, so what gives???? (My next version is: "14.2.13")

28 Replies

Avatar
English SpotOP
I have tried searching around the docs and stack overflow for anything related to this but I haven't seemed to find anything that relates to the situation I'm in. I'll pulling my hair out over this...what's worse is that the build step was working at some point and I have no idea what changed to make it no longer produce files in the out directory.
Avatar
Miniature Pinscher
So if you delete the .next folder, run the build again, you are still able to start your site with npm start?
Avatar
English SpotOP
I only deleted the out folder, let me try right now
Okay yeah after deleting out and .next, I can run build and then run start and it gives me my website on port 3000
Avatar
Miniature Pinscher
So it's there but just hidden.
cd into the dir and do ls -a
if you're on unix
Avatar
English SpotOP
I'm on windows but I can just turn on hidden files I think
Avatar
Miniature Pinscher
yeah or do dir /adh
Avatar
English SpotOP
yeah nothing new popped up (other than the .git folder)
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/27/2024 11:43 AM .next
da---l 10/27/2024 9:55 AM node_modules
da---l 10/11/2024 10:53 AM src
-a---l 10/27/2024 10:40 AM 284 .eslintrc.json
-a---l 10/27/2024 11:01 AM 391 .gitignore
-a---l 9/27/2024 1:31 PM 419 components.json
-a---l 9/27/2024 3:07 PM 315 compose.yaml
-a---l 9/27/2024 3:33 PM 783 Dockerfile
-a---l 9/24/2024 3:34 PM 228 next-env.d.ts
-a---l 10/27/2024 11:19 AM 143 next.config.mjs
-a---- 10/27/2024 9:55 AM 222409 package-lock.json
-a---- 10/27/2024 11:04 AM 1327 package.json
-a---l 9/24/2024 3:34 PM 135 postcss.config.mjs
-a---l 9/27/2024 2:58 PM 827 README.Docker.md
-a---l 9/24/2024 3:34 PM 1450 README.md
-a---l 9/27/2024 1:31 PM 1668 tailwind.config.ts
-a---l 9/27/2024 1:28 PM 578 tsconfig.json
Avatar
Miniature Pinscher
I said cd into the dir
so into .next
Avatar
English SpotOP
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/27/2024 11:43 AM cache
d----- 10/27/2024 11:43 AM server
d----- 10/27/2024 11:43 AM static
d----- 10/27/2024 11:43 AM types
-a---- 10/27/2024 11:43 AM 1153 app-build-manifest.json
-a---- 10/27/2024 11:43 AM 82 app-path-routes-manifest.json
-a---- 10/27/2024 11:43 AM 967 build-manifest.json
-a---- 10/27/2024 11:43 AM 21 BUILD_ID
-a---- 10/27/2024 11:43 AM 94 export-marker.json
-a---- 10/27/2024 11:43 AM 511 images-manifest.json
-a---- 10/27/2024 11:43 AM 4643 next-minimal-server.js.nft.json
-a---- 10/27/2024 11:43 AM 30318 next-server.js.nft.json
-a---- 10/27/2024 11:42 AM 20 package.json
-a---- 10/27/2024 11:43 AM 959 prerender-manifest.json
-a---- 10/27/2024 11:43 AM 2 react-loadable-manifest.json
-a---- 10/27/2024 11:43 AM 4602 required-server-files.json
-a---- 10/27/2024 11:42 AM 831 routes-manifest.json
-a---- 10/27/2024 11:43 AM 504523 trace
The only index.html file that I can find is inside of /.next/server/app
Avatar
Miniature Pinscher
I'm a bit unexperienced with static exports, but apparently next start always attempt to start your project with a server. It's weird that you're still able to do that given your next config. Are you sure you're even in the correct directory for your project?
Avatar
English SpotOP
Hahah yeah I think so, I'm just at the root of the project (where the package.json and other config files live)
Avatar
Miniature Pinscher
If you can, upload your codebase to a github repo and share it here (or a minimal reproducible repo).
Avatar
English SpotOP
yeah np gimme one sec
Let me know how it goes 🙂
Avatar
Miniature Pinscher
Ah, no wonder it didn't make any sense. You forgot to export your nextConfig.

Replace the next.config.mjs with:
/** @type {import('next').NextConfig} */
const nextConfig = {
  output: "export",
  images: {
    unoptimized: true,
  },
};

export default nextConfig;
Avatar
English SpotOP
oh boy haha
that fixed it
you are a genius
Avatar
Miniature Pinscher
On the contrary, I should have picked that up by just looking at your config instead of having to clone your repo. I'll blame it on being close to bedtime 😄
Avatar
English SpotOP
haha regardless, I appreciate the help. ❤️
you have saved me from quite a bit of pain and suffering