Monday 28 August 2017

[Newbie Question] Deploying nodejs apps like Next.js

I'm new to Node and I'm trying to figure out how node based apps are normally deployed. Specifically Next.js.From the tutorials and googling I've done it seems like you upload a server.js file, run node server.js, then run something like pm2 to ensure it continues running. This is great for writing hello world, but I feel like the frameworks and applications I've come across get deployed in much different ways than that.For example Next.js lets you run a build script which then compiles to a dist folder. I can upload the contents of this folder, but theres no clear file to start the app from. No root files seem to be the equivalent of the server.js I've seen in tutorials.The only logical assumption that I can come to is you treat deployment similar to you treat development. That your package.json file should have a start script specifically for production. So you upload your entire repo, run an npm install to get the node_modules folder on your server, then run an npm start command with the proper port. I feel like I'm missing something here or over complicating it.Can anyone point me in the right direction?

Submitted August 28, 2017 at 05:06PM by burgerlove

No comments:

Post a Comment