0

So i have a NextJS project going on. And everytime I try to run NPM RUN BUILD i don't get an index.html file in my public folder, and that causes google firebase deploy not work properly.

It used to work before but not anymore, why is that?enter image description here

  • Do you have an `index.js` in your `pages` folder? The `'public` folder is for static file serving, it's not where the index is being sent. https://nextjs.org/docs/basic-features/static-file-serving – Julio Corzo Sep 24 '21 at 07:14
  • yes i do have an index,js file in the pages folder. – ghaith haddad Sep 24 '21 at 14:38
  • 1
    When you build a next project, the files that are generated go into `.next`, not `public`. https://nextjs.org/docs/advanced-features/static-html-export – Julio Corzo Sep 24 '21 at 16:33
  • ok, so what im trying to do is host my nextjs project on firebase. now when I run firebase deploy for hosting, firebase keeps creating an index.html and 404.html files in the public directory and serves that only. how can I make it serve the actual site? – ghaith haddad Sep 25 '21 at 12:30
  • I have the same issue, any ideas on how to solve it? – MedCh Oct 08 '22 at 23:03

1 Answers1

1

You need to go to your package.json and modify the build script into "next build && next export":

  "scripts": {
    "build": "next build && next export",
  },

Now run the npm run build command, that will generate an out folder containing your static website (use it's content same as if it was called public).

Example of the package.json

Example of the out folder