How do you get a server to upload and work for your game? - node.js

I've been searching all over the web and have attempted to upload my node.js based server up to a few various web hosters with no result. As far as I know most hosters don't support node.js to begin with, and I have a list of a few that do.
But my primary question is, how do you get your server working on this hoster in the first place? do you just upload it? does it sort of self run once uploaded? do I have to access that hosters cmd in order to get it running?
Sorry for what is probably a very newbish question, which I assume it is as I have yet to find a guide that covers this because it is apparently too basic. They always seem to skip this part:s

You'll just need to upload your files to a web host that supports javascript and offers command line access; for example, check out Amazon's free scalable offering. Once you have the files uploaded, just run them from the command line:
% node node.js

Related

How to deploy a React + Express app on a local network?

This is my first post here, let me know if I do it wrong. I would like to start by mentioning that I'm kind of a beginner developer. I've had a bunch of classes, but it's also my first time working on something of my own, from beginning to end (emphasis on "end").
I'm working on a relatively simple app, for user management (CRUD, with different levels of authorizations) and shop management. I was given the choice of the tools, framework, language, etc, to use, with the only constraints that 1/ the main device to use it will be a tablet most of the times 2/ nothing should be hosted online. I wanted to get more familiar with Javascript so I went with creating a React app (front) with Express Nodejs (back) and a MySQL database I access via Sequelize.
Development is going fine (for the most part thanks to many great posts here on SO), but I just got hit by the reality that I have never tried to build the app and see if it runs the way I intend. And I do not know how to do it. I should have researched that earlier.
So far, in development I always tested everything on PC and phone by running npm start (front end) and node server.js (back end), and the client runs in a browser (when using a phone I access the IP adress and port, like 192.168.x.x:3000). Backend listens to the 8080 port no prob, access to the MySQL database works as intended thanks to Sequelize. Frontend listens to port 3000 to display the user interface on the browser, and React makes it easy to develop features in front, and quickly troubleshoot them. Everything works fine, and as expected, anyone in the same network (and with a web browser) can access and use the app that way.
This is the behavior I want to replicate with a production build : having a computer host the build, and run the "server" so that the app is available to any device in the local network. So I guess I need to somehow make my build in a way to make it possible to turn on and off the "server" at will, maybe via a .exe ? Or turn it on at the same time as the computer ?
I know I should have researched that earlier and not doing so was a mistake. All I know is I'll have to use npm run build, to get the build folder, but I don't know what to do from there. Could you help me figure it out ? Among many things I'm not sure of, is whether or not the host computer (not mine) needs to have node.js installed ? Does it also have to have MySQL installed ? Do I make a single build that incorporates the backend and the frontend, or do I build both separately ? If so, how ?
Let me know if you need to see part of the code. Thanks in advance and have a great day.
EDIT : App was created using create react app
There are options to deploy on cloud like Cloud Servers. But I think you're looking for hosting the application on the local machine. You need to create a service, bundle the application and serve whenever you want.
Following link might be helpful
https://www.section.io/engineering-education/compile-your-nodejs-application-into-a-exe-file/

Connect to windows server from node js

I'm not very experienced in programming and have a problem that I'm finding hard do solve.
I have a web app that is on a ubuntu server, that is running on node js. That web app creates an excel file on the back-end that is to be read by another excel file and execute a vba that gives as results in a software that only runs on windows.
I tried the software on a windows server and it seems to run, so no problems there.
My question is: how do I make my web app excel file be stored in the windows server and how do I call the files on that server to run from node js?
Can anyone please share some resources on where I can explore this subject please?
Thanks in advance,
Ana
The following is what I advised the OP to do in the comments, only longer and with more explanation.
First, install NodeJS on your Windows server. You can do it by either installing it from the official Downloads page from NodeJS, or use a version manager such as nvm, with a Microsoft tutorial on how to do it that way. This step is up to you.
Host your back-end part (the one that creates the excel part) on the Windows server. That way, the file will be stored in the same filesystem the "software that runs only on Windows" is on.
The problem now is determining if there is any way to run the "software" via command line. Since I don't know the software name, I can't look that up but if it can, you'll have to check child processes via NodeJS.
Now, if this software has no way to be run via command line, and if they didn't publish any sort of programming interface (what is called API in the real definition of the term), chances are that you will not be able to achieve what you want to.
If you want me to clarify or explain more on some points, please let me know in the comments so I can edit my answer.

How do I properly upload a localhost website online?

I have a ReactJS project for my Front and a NodeJS project/server using Express for my back. My Front depends on my Back because for example in the Login part, I ask the server if the user is already in our database.
To execute my project, I just open 2 terminals and do npm start in each Front and Back.
I know that in order to upload a website with a personal domain name, I should:
Buy a domain name
Pay a subscription to a web-hosting website like GoDaddy, Bluehost, Hostgator etc.
If I pay a subscription to some web-hosting website, will I be able to put my Front AND Back? I have seen some tutorials online and people just make a simple HTML/CSS/JS website and upload it. I never see anyone uploading their own Server and making requests to it.
I'm not asking to merge both my Front and Back. I want to know how do people upload online their React front and Node Server online, for them to be always executed and talking to each other. I just can't see the relationship and explanation on how uploading both.
Your react frontend doesn't really need a server, you'd need to build a release bundle and that can be served from any static filehoster. For your backend though you need a node.js hoster like AWS or heroku, follow their tutorials to upload your project.
You could also then serve both from the same hoster and read into connecting frontend and backend like mentioned by #FedeSc
An easy solution for your use case could be digitalocean or any similar site that offers a whole virtual system to operate with. You can then ssh into the server as it was your computer and use the terminal there. It is cheaper than Heroku if you wish to make your site available without 30 seconds waiting time (that is what Heroku does in a serverless fashion if you are on a free plan). There are dozens of sites like this but I had good experience with digitalocean and a basic plan is $5/mo.

Using Nodejs with IIS for REST service using Express

We're using Nodejs + Express to create a RESTful web service. During testing we kicked off the service via the command-line, i.e., node mim.js and and tested the service using http://server:9999/mim/GetEmployeeData and that works fine.
The node application lives in inetpub\wwroot\myapps\mim and we want to be able to access it like so:
http://apps.mydomain.com/mim/GetEmployeeData
We're not quite sure how to get this to work with IIS, however. Looking for some help with respect to this.
Thanks in advance!
See this Hosting node.js applications in IIS on Windows tutorial:
https://github.com/tjanczuk/iisnode
It explains many different scenarios and since you din't post a lot of details it's hard to give you a more detailed answer other than pointing you to a good documentation about the thing that you're trying to do.

How to replace IIS with Node.js for simple websites

I am coming from Microsoft world so please bear with me on this. I was told I could install node.js and use that as a web server instead of IIS. This is a very small business application. In IIS I can create virtual directory and point to the location of the web page and everything works just fine. Based on very little I read, I have few questions;
Is it possible to run node js as a windows service or any other form so that it runs for ever? I did find the forever package that I think I can use.
In IIS, I can create virtual directory set the port and thats it, I have myself a website.
I do not see any examples where I can use a directory where I have a web page, written in java script and point it to run as a web site. All the examples have some thing like server.js and that runs and routes the call. what is the other way to host web sites and use node.js to simple run as a fast web server.
I was told I could install node.js and use that as a web server instead of IIS.
This is true, but as you already found out then you are in charge of providing for things that IIS was already doing for you (e.g. automatically restart on reboot, or on crashes, hosting multiple sites by creating virtual folders, et cetera.)
You can indeed get all of these things worked out in Node.js and there are several libraries that help on each of these areas. It's not too hard but you'll need to do a bit of researching.
You can also run Node.js behind IIS. Take a look at iisnode http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html
Is it possible to run node js as a windows service or any other form so
that it runs for ever?
The library Forever takes care of restarting the site when it crashes...but I don't know if you can run it as a Windows Service. I haven't tried that.
In IIS, I can create virtual directory set the port and thats it,
I have myself a website.
I assume you are talking about a site that serves static HTML files, right? If that's the case that's very easy to support in Node.js either writing your own web server or using Express.js to serve static files.
I do not see any examples where I can use a directory where I have a web page,
written in java script and point it to run as a web site. All the examples
have some thing like server.js and that runs and routes the call.
Here is an extremely simple example to serve plain HTML files in Node.js https://gist.github.com/2573391 Don't use this in production, though. It's just an example and it does not have any kind of error handling or security.
what is the other way to host web sites and use node.js to simple run
as a fast web server.
As others have said, you should look into Express.js http://expressjs.com/ It provides some of the infrastructure that you are very likely going to need when building traditional web sites.
You say you're running a "very small business application" behind IIS. Unless it's written for Node.js (in JavaScript), it won't work.
There are no examples pointing to a directory and running that as a website, because that's not how things are done in Node.js. You write a Node.js-application and pull in a webserver-library.
Put simply, In Node.js, you don't embed the appliation in the webserver; you embed the webserver in the application.
When I used node.js, I redirected HTTP requests by a proxy server, nginx. I don’t know if you can directly bind node.js as an HTTP server, but for what’s it worth, nginx is pretty nice!
First things first, allow me to share an introduction. IMHO you should take this decision ( of moving from IIS to nodeJS) by adding various parameters. I belong to the Java & PHP community yet I use NodeJS to achieve extremely specific implementation where NodeJS perform the fastest ( fast IO, AJAX-JSON responses & more ). As you are coming with a Microsoft background you should bare with less comfortable solutions.
Yes, its possible to run NodeJs as a windows service and Forever will do fine.
and yes you can create "Virtual Directories" but by creating symbolic links to each of your customer's web site.
I recommend to take a good look at bouncy & express, If you're willing to take this step then these packages is just what you need.
Cheers!

Resources