I need to build My React NextJS Project on local to host it at Appache server, when I run command run build
it did not generate build folder.
I R & D on it, everyone recommend ZEIT – Next.js build with Now
but it build project on cloud but I need a build for my local appache server. So please help me out.
Here is an my of package.json:
......
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "next start"
},
......
Automatic Setup After the installation is complete: Run npm run dev or yarn dev or pnpm dev to start the development server on http://localhost:3000. Visit http://localhost:3000 to view your application. Edit pages/index.js and see the updated result in your browser.
You don't need a node server running 24/7 for hosting your application. Also, if you don't use getServerSideProps, Next. js by default will pre-render your page, this page gets cached on a CDN. So yes you can make API calls to your PHP backend, without the need for a setting up a nodejs server yourself.
Next. js makes it easy to scale multiple pages because it can individually select how to render each page either on the client, the server, or hybrid.
After so many struggle, I found answer of my question I have to add following line in my package.json under scripts:
"scripts": {
......
"export": "npm run build && next export"
.....
},
Basically I my case, npm run build && next export
was complete required command to build NextJS project. So after adding this into package.json you just need to run in terminal:
npm export
and it will generate complete build for nextjs project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With