How to compile Node.JS desktop app? - node.js

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.

Related

how do i make an exe of my node cli application

I'm pretty new to coding and I've made a small project in nodejs with a few tools which is all run on the command line. I'm really struggling to find a way to make this an exe file and allow other people to download said exe file and run the app. Could anyone point me in the right direction of how to do this?
I've looked at packages such as nw.js and electron but these seem like they're for browser based applications - could just do with pointing in the right direction

How to launch html file (with css and js files included) on remote server on node.js with angular 2

I started working with Angular 2 and have one issue.
I compiled my app for production through "ng build" and got an index.html and other files like js and css in this folder.
I need to publics them on web
Im using remote ubuntu on digital ocean.
I found this nice script, which solved a problem, but to enter a project I need to print in a browser a path like this: somehost:8080/index.html.
Can you help please and explain please, how I can use a path like somehost:8080, or just somehost:8080/index, but without a file extension? I found of course, even simpler scripts, but they dont serve js and css, which are included.
And next question, actually main, is this decision the most elegant to provide an entrance to the app, or there is a better and smarter way? Afterwards, Im thinking about PM2, because all that I need is to launch it like a linux service and to reload the app, if it will be crashed.
Thanks!

Resources to start building my own mozilla

I am trying to learn and build my own version of mozilla with customizations. But I have no idea where to start and how to proceed. Can someone enlighten me in the following aspects:
1.Where to clone the latest open source code for mozilla
2.Where to learn the browser architecture and file structure(For linux/Ubuntu) So that I can customize the codes and add my own custom
addons.
3.How to debug and build the browser for Linux.
I heard its purely HTML,CSS and javascript. I have a low level expertise in all of this but no idea where to put together all of these. Please enlighten me with any resources. Basically I need a kickstart. Googling didn't gives me any such basic tutorials. I hope someone here would have tried these things before :) Any help is much appreciated.
There's a very handy guide on how to build Mozilla Firefox on MDN. Here's an outline of the steps:
Install the build prerequisite for Linux as described here - wget -q https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py -O bootstrap.py && python bootstrap.py
Clone the repository locally using mercurial - hg clone https://hg.mozilla.org/mozilla-central
Change the current working directory to mozilla-central and then issue the ./mach build command. This will produce a vanilla version of Firefox, unbranded (aka developer build).
Once building is complete, you can run your copy using ./mach build or package it using ./mach package.
In order to customize your build, you need to both change the code and the building options. The latter can be done by creating a .mozconfig file in the mozilla-central directory and adding the desired build options there.
Where to learn the browser architecture and file structure(For
linux/Ubuntu) So that I can customize the codes and add my own custom
addons.
To understand a bit more about the structure of the Firefox source code, you can have a look at this nice overview. Basically, each top directory represents a component of the browser (e.g. dom, browser, toolkit, ...). Depending on what you need, you have to change the code in the related directory. When you're lost and trying to find what to change, DXR can come to the rescue: it's the official Mozilla code search engine.
You mentioned addons: I'm not sure what's your objective, but if you just need to develop an addon, then you don't really need to build Firefox from scratch. There's a lot of documentation about how to create addons, if needed.
How to debug and build the browser for Linux.
The first part of this answers explains how to build. In order to debug, once you've built Firefox, simply run it with the command ./mach run --debugger. This will allow you to debug the C++ core of Firefox. However, for most of the front end code (which lives in browser/*), that's not needed: you can simply run Firefox and use the Browser Toolbox.

How can I run a Chrome extension in NW.js?

This question is pretty short and self explanatory. I'm wondering how I can run my Chrome extension in NW.js.
I know you can run an app in NW.js and I think you can run extensions as well?
I can't find much on the topic. Back in 2013 the way to do it seemed to be:
nw [path to manifest.json] --load-extension
Any ideas are appreciated!
Yes you can.
First off, download the extension you want. For this example I'll be using this debugging tool, which adds an additional tab in the dev tools window.
Inside your NW.js package.json file, ensure you have an entry called chromium-args.
Ensure its value contains --enable-extensions --load-extension=relative_path_to_extension_manifest.
My package.json looks like this:
After restarting the application, the extension shows up as expected:
Something I'll add is that the full Chrome API might not be available to you. I couldn't find info about what NW.js supports, but Electron definitely does not support the entire API, so this might have similar restrictions.
I also noticed you mention in the comments that you need to assign a hotkey of sorts. I'd need to know what you were trying to do, but essentially you have the option of either using a browser mechanism such as addEventListener('keydown', myHandler) or using the NW.js API depending on your exact needs.

View node.js source code on local machine

I have node.js installed on my mac. However I am not able to find the the source code.
The 'node' binary file is located /usr/local/bin however since its binary, I can not view it.
For example I want to see internal of console.log function.
On joyent github I can see the code but I want see it when I am offline via some editor like webstorm.
https://github.com/joyent/node/tree/master/lib
Can someone please help.
Thanks
Locally you have Node.js installed. To make your life easier, Node.js developers have already compiled Source into runnable Application.
Because you downloaded already compiled Node.js (that is OK, and sensible), you need to also download source-code if you want to access it offline.
Downloading source-code is just as easy, you can grab the latest code available at the same location as you specified: https://github.com/joyent/node. Look for "Download ZIP" button on the bottom right.
In case of webstorm this link will help - http://www.jetbrains.com/webstorm/webhelp/node-js.html - see "Configuring Node core module sources"

Resources