How to upload Node.js Application to FTP server? - node.js

I am kind of new to Node.js but I built an application and am pretty happy with it. I was wondering how would I go about uploading my Node.js application to an FTP server? Is it even possible to do this?

A Node.JS application is just a collection of files. You can upload them to another computer using FTP just like any other files.
That probably isn't what you are trying to ask though.
If you want to host a website built as a Node.JS application then you need to be using hosting that either:
Explicitly supports Node.JS (Google finds this list) or
Gives you full admin access (such as a virtual or dedicated server)
Such hosting will generally give you (at a minimum) shell access (via SSH) which you can use to run the Node.JS application.

Related

deploying a node.js application on windows

I have developed a node.js application. I have two files serverpart.js and index.html (the html file is already referenced in server.js). During my development I run the application using command node serverpart.js and then access the client using http://localhost/8070. That was nice but now my application is ready and I want it to be accessed from other machines on the LAN. So please advice where should put these files(in some particular director). Do I need any web server for that please suggest.

Electron like node integration in nodejs web server

I'm new to web servers in nodejs and i'd like to know if there is possible to have an electron like node integration in a web server (to be able to use nodejs in index.js script file linked to index.html)
Thx for all :)
It's not possible. Browsers control the way that client side JavaScript is executed, so it's just technically impossible to connect both runtimes in any way that works on client machine, you'd need a customized browser, which is what Electron basically is. And neither should you want to - if the runtimes were connected in that way, any user could execute arbitrary commands on your server.

Is it possible to build a electron desktop app without node server?

I want to develop a desktop app with electron without using nodejs (i don't want to use any server, a plain desktop app) to access the local files in the machine.
Node.js is a Javascript runtime, using it doesn't mean you need to use it to run a server of any kind. In fact, Electron uses Node.js internally to implement "lower level operating system interactions", like the ability to read local files.

Running related apps in different servers

I have NodeJS server for my iPhone and Android apps and I want to build an admin panel as desktop application using Electron.
From my research, I found out that Electron depends on its own version of node and it can't run on other server instance.
My questions are:
1) is it advisable to implement the admin panel using Electron knowing that it depends on its own version of NodeJS?
2) is there away to integrate my current NodeJS server for mobile apps to my Electron? because using two different servers will be costly when it comes to hosting them
3) what are other alternatives that enable me to implement cross-platform desktop application using my current mobile apps server?
NOTE: The admin panel server functionality are completely different from mobile apps.
1) is it advisable to implement the admin panel using Electron knowing that it depends on its own version of NodeJS?
Yes, that is perfectly fine. You can access your current node server directly from your electron app, or create a new node server that electron will access.
2) is there away to integrate my current NodeJS server for mobile apps to my Electron? because using two different servers will be costly when it comes to hosting them
You can run multiple nodejs servers on one machine (just use different ports when starting the servers). This is one easy way to get around this issue, or you can just have a group of /admin endpoints that handle all admin related functionality. Think of electron has a front-end that can be distributed across various platforms and access any back-end you choose.
3) what are other alternatives that enable me to implement cross-platform desktop application using my current mobile apps server?
Electron / nwjs (node-webkit) are the only two that come to mind. Although there are probably others.
More Electron/nwjs details:
Just think of these as browsers that allow you to write nodejs. Therefore, within the browser you can access databases you ship with your app, or anything on the users file system. You can also make requests from your app to already created nodejs servers. Also, they allow you to easily package up your app for cross-platform distribution.

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