Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can You Build a Next.js Server While That Server is Running?

Tags:

next.js

This seems like a simple question, but I couldn't find an answer in the Next documentation. If I have started a Next.js server:

$ npm run start

and I get an update to the site:

$ git pull

can I re-build the server:

$ npm run build

while it's still running ... or will that crash the server?

If it will crash it, is the a best practice to build everything to a separate directory, and then copy it over to deploy?

like image 449
machineghost Avatar asked Oct 15 '25 02:10

machineghost


1 Answers

I had the same thought, every time I update my code and build it for production, I am stopping my server and restarting it.

To experiment, I tried: npm run build. npm run start. Then, made a change to the code. I kept the server running. and in a different terminal window,I did npm run build. But, unfortunately, it crashed the app. So, I had to stop the server and ran npm run start again in the original terminal window.

Unless it is a completely static site or in dev mode, I think stopping and restarting the server is necessary.

like image 87
Noby Fujioka Avatar answered Oct 18 '25 06:10

Noby Fujioka