I’ve almost finished a functioning chat client that I wrote with node, express, and MongoDB, I’d like to implement it to my website as one of the web pages but I’m little confused how the server I wrote is supposed work when there’s a company hosting my website. Do I just place my “server.js” file inside of my public_html folder in the admin area like a regular web page?
Hopefully, my question is clear I’m finding it difficult to explain.
No, “public” is only for static, client-side files.
Exactly how to set up depends partly on what hosting solution you’re using. The simplest option is something like Glitch, where you can basically just dump your files, configure your package.json, and you’re good to go. They have a few boilerplate options if you want to see how a typical app is laid out.
Once you have a server up and running with Node.js on it, you can start it the same way you usually would, i.e. node <file path> or npm start with a start script specified in package.json. You may also need to configure ports (usually 80 for HTTP and 443 for HTTPS).