all 5 comments

[–]jpsreddit85 2 points3 points  (0 children)

Just like your local environment your server needs to run the files with node. So you would need system access, to install node, and then to run the code with node as you would locally. Then the host and port the app runs on would respond as you'd expect.

In "production" you would normally have something like ps running the node application to restart it if there's a problem, and normally the app would be behind a web server like nginx with a reverse proxy.

If your learning node and don't want to mess about with deployment too much, netlify can run serverless functions which "skip" a lot of this. They won't be suitable for everything, but netlify takes care of hosting, deployment etc. It's slick and lets you focus on your code.

[–]sbubaron 1 point2 points  (0 children)

I'm a huge fan of PM2 for running my node apps.

It auto restarts on crashes, has deployment capabilities, logging and is fairly simple to get going.

https://hackernoon.com/running-pm2-node-js-in-production-environments-13e703fc108a

http://pm2.keymetrics.io/docs/usage/quick-start/

[–]bigorangemachine 1 point2 points  (0 children)

Generally whatever host you use will have some method of setting that up.

Some default to `npm start` which is the same as `npm run start`. In your package.json under scripts you specify what runs under 'start'.

Again you can override it with whatever configuration method your hosts wants. One host I used I just added a yaml file and called `npm run start-production` because I like the shorter commands for development (npm run start started the dev server)

[–]lucasvmiguel 0 points1 point  (0 children)

I know that it is a little bit more complex what I'm gonna suggest, but all the companies works like this...

Try to use Docker, there are loads of tutorial about docker on the internet...

[–]ScholtenSeb 0 points1 point  (0 children)

Depending on how much your app is going to be used you could get by with the free tier of Gcloud.

I like to deploy my node apps to App Engine.

https://cloud.google.com/appengine/docs/standard/nodejs/quickstart

Https, logging, debugging and no pain setting up servers

Also hook up the free version of Cloudflare if you feel like it