Deploy a node.js application (windows) - node.js

for a customer of mine i'm developing a node.js app.
I want to give him a simple setup program that handle the installation of node and relative modules in automatic without having to access the web.
Which is the best and efficient way to do that?
Thanks in advance

Just give him the node.js installer und zip your app (with node_modules directory). He just has to install node.js and extract the zip file. You could write a .bat file which starts the app. That should be easy enough.

Related

Angular + Electron app: query web API or DataBase according to deskop or web mode

I would like to build an app using Angular + Electron. My app should be able to run both on desktop and browser platforms. I'm considering to use angular-electron starter kit (but I'm open to other possibilities).
What concerns my is the way I read and write data. The data must be stored in a MySQL database. Ideally I would like to:
make the app call an api when NOT running on Electron (browser mode)
make the app query directly the mysql database when running on Electron (desktop mode)
I know I could check for window && window.process && window.process.type to let the app understand wheter running on Electron or not, however I'm a bit concerned about how to handle this. Also because I probably need to import node packages like mysqljs but ONLY in the desktop mode.
You can simply pass in different environment files in Angular during build this allow you to control the environment variables so that you can tell that it is a web app build or an electron app build.
https://angular.io/guide/build
EXTRA
But if you are importing binary packages this is where it gets tricky. I dont think there is a clean way for you to do conditional imports. I did not manage to find a way to do it cleanly and sort of maintained another repository for all my services that needs to import binary files.
To import the binary files you will also need to edit some webpack settings to tell angular to not compile/include the binary files during the build process so that you can use you librarys like mysqljs that require binary files. There is also some settings on the electron end to make binary files compatible for different platforms ie Windows, Mac , Linux. Basically it is really a pain to do it.
Link to how to edit webpack settings for angular 7+
https://github.com/manfredsteyer/ngx-build-plus
I will totally suggest you not to do it unless you really have a very good reason that you need to use these libraries.
EDIT 10/1/19
Okay I was referring to the MySqlJs but it seems like it does not have native modules modules. Native/binary modules basically means javascript code that relies on c++ compiled binaries(Or any native language like rust...).
For my case I was using the grpc modules which has a native dependency. Had to switch to grpc-web in the end.
I will add some footnotes here if you ever need them
https://electronjs.org/docs/tutorial/using-native-node-modules
Node.js / npm - anyway to tell if a package is pure JS or not?

How to compile Node.JS desktop app?

to gain more experience coding and support good projects, I recently got into open source projects and Github. After looking for a project I would like to work on, I found Soundnode (https://github.com/Soundnode/soundnode-app). The project uses NW.js, Node.js and Angular.js.
The question is very fundamental: How do I run the NW.js desktop app from the given files?
I was able to compile the app once, using the bash command open -n -a nwjs --args "/Users/example/path/app". But how do I compile the changes? After changing the index.html file, which is the start for the application, I have to terminate the NW.js app and start it up again (otherwise nothing will happen) and then it opens again the same, unchanged, original app (I changed some html text to see if would load the changed index.html).
Could anyone give me a quick guide how to work with this? What I want to change and everything else I will try to figure out on my own. Just need somebody to give me a head start :)
Best Regards, bbrinx - eager to learn.
nwjs application works next ways:
direct load web files from FS or web
archive files to zip package.nw
Check nwjs manual and docs: http://docs.nwjs.io/en/latest/ and https://github.com/nwjs/nw.js/wiki
Easiest way to compile your app is to use Web2Exe. It can compile for Win, Mac, Linux.
You can use browser tools for developing/debugging your application. Set toolbar option in true in window section in package.json file to see browser elements in your app.

nwjs app javascript protection?

So nwjs is a neat little framework that enables node apps to run in desktop mode independent to platform. But the way I package my files is pretty raw.
I zip my node app directory into a .nw file, and I copy it to an existing nwjs app's content folder. Then this means that anyone with some knowledge of nwjs will be able to literally unzip the .nw file and dig through the app directory. WTF. Is there a way to protect my files in my nwjs app?
You can compile the javascript files with snapshot:
nwjc source.js binary.bin
then load the compiled js in your app like this
require('nw.gui').Window.get().evalNWBin(null, 'binary.bin');
for more info, check this out.

Packaging and distribution of node web-kit app done using Sails

I am new to Node-webkit. I have created a simple application and I would like to know how to package and distribute a node-webkit App done using sails. I want a complete .exe file which would help me install my application in any computers.
Thanks in advance.
Please refer Packaging and Distribution
for creating a executable file for a node webkit application

How to write a node-webkit application with custom modules?

I am currently writing a node-webkit application. The application supports certain modules which lie in the module folder inside the application.
I would like to dynamically install and remove those modules from inside the application. For that i would need to dynamically write inside the application.nw file. Is there a best practice solution to my problem?
That's not really a good idea. Just create a folder for app files and put downloaded packages there.

Resources