P
P
prolina2020-06-28 00:15:06
Node.js
prolina, 2020-06-28 00:15:06

How to run node js server on hosting?

I have a project written in angular and a server written in node.js. I would like to publish the project on the hosting, but I do not know how to make the server start. Now I run it in the second terminal window with the node server.ts command. What do I need to do to get the server running on the hosting?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
McBernar, 2020-06-28
@McBernar

Rent a server, install ubuntu, node, nginx, install pm2, which will run your script, configure nginx to proxy a request from your domain to a raised node, upload project files, make npm i and run.
Google tutorials. Here fuss for half an hour maximum. Digitalocean has some great setup guides for this. You can also rent a server there.

A
Albert Komarov, 2020-06-28
@KomaroffAlbert

To run nodejs scripts on the server, it is recommended to use forever
https://www.npmjs.com/package/forever
In this case, the process will not end when the console window is closed, because runs in a separate daemon.
Also, forever restarts the script if it crashes. By default, it makes 5 startup attempts with an interval of 1 second. But this can be customized.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question