Electron JS/Node JS desktop app as a local network webserver - node.js

Is it possible to make an Electron JS desktop app that is a web server, so that when we start the app the server will also start and we can access it from other computer within the same network/LAN?

Yes, it is.
Yout can run you server (express or just bare http/https/http2) on main process.
Also you can child_process.fork() or child_process.spawn(). It works fine.

Related

How can I convert a Node Js web application to a desktop application?

I have created a Node js Web application which is running on an express server. It is a web automation application which is made using puppeteer. I want this app to run in headful mode which is not possible if I deploy this on servers (for eg Heroku). So instead of deploying this application,I wanted to create a desktop app which runs this application on the local host everytime. Is there any way to convert this web application to a desktop application and run it on local host through the desktop app only?
Your best bet would be using Electron.
It is used for cross-platform apps with Nodejs and interacts like website, so you wouldn't need to rebuilt your app from scratch.

How to run separate node server in electron app

I'm building an Electron app using React.
I couldn't get the native node module "printer" to work in electron. There were problems while rebuilding native node module. I need the list of printers that are connected to the device in my app. Then print text using specific printer.
So I decided to run an express server separate from electron. Express app needs to have its own node_modules and package.json. And client side will connect the local node server via http request to localhost.
Is it possible to do so? How can I add express app to the dist folder which is created by electron-builder and make it run when electron app is launched?
There is already a way to way the native printing functionality in electron.
Please follow the below link.
https://www.electronjs.org/docs/api/web-contents#contentsgetprinters

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.

how to deploy nodejs rest api with express framework on production server windows

I have created a node.js rest api created using express framework for routing. I have used tutorial
Now I want to deploy that rest api on actual production server. How to achieve that thing.
I have gone through below links.
Deploy node js application with express framework on production mode --- Only for linux. I need for windows.
Deploying NodeJs Express Rest API to Windows 10 IoT -- a little bit similar problem but no solution
https://stackoverflow.com/a/38652869/2810015 -- this said to run npm start on production server after copying all of the files on server. But this is not working fine either.
Any help will be highly useful.
You use pm2?
Usually I use it to start the application. It works for both windows and linux. He leaves the service initated, and in case something happens that knocks the service up again.
You install it on the server, and instead of using it
node server.js
You use the command below
pm2 server.js start
Link: http://pm2.keymetrics.io/docs/advanced/pm2-module-system/

How do I create a local server in packaged chrome app which runs offline?

I want to create a Node.js server in chrome app so that I would be able to run node.js applications through it. The app would run offine therefore the server had to be local.
As I was not able to do my setup in Chrome app, I used node-webkit for making my project to work and setup my project as
General Information
Express Server is started on port no 3000.
EJS is used for HTML renderer for ExpressJS
PeerJS Server is started on port no 9000.
IndexedDB is used for database purposes.
PouchDB is used as wrapper for IndexedDB
blueimp-file-upload is used for FTP over express server.
AngularJS is used for creating modules for front-end.
LUMX is used as UI framework.
jQuery is used for DOM Manipulation.
Velocity is used for smoother animations.
Complete code can be found at my github pulic repo
https://github.com/sumitkumar1209/PQ-PinQuip-Messenger

Resources