Is there any standlone gui module for node application [closed] - node.js

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to build a code editor in nodejs. There is option like using an express server to show editor and to execute code in backend. But that would require a browser. So I am looking for node modules that can provide standalone gui for windows platform.

There are a couple of different options, depending on how you want to proceed.
Option 1:
Use something like QT or GTK bindings to make a more traditional GUI application. These options generally are just Node bindings to the C/C++ API that GTK and QT expose. See node-qt and yue. Although these seem to not be actively developed.
Update:
You can take a look at NodeGUI: https://github.com/nodegui/nodegui
NodeGUI is a javascript library for building cross-platform native desktop applications with JavaScript and CSS like styling. It uses Qt under the hood and works on Mac, Linux and Windows.
It also has a react based renderer called React NodeGUI which is like React Native but for desktop: https://github.com/nodegui/react-nodegui
Option 2:
Use a framework that takes HTML, CSS, and Javascript and bundles it into a standalone HTML5 app. There are a bunch of frame works out there that do this. Examples include node-webkit and AppJS among many others.

I recommend using an HTML/JS/CSS Framework
Option #1: Electron by GitHub.
Website | GitHub Repo | Releases
It's easier than you think
If you can build a website, you can build a desktop app. Electron is a
framework for creating native applications with web technologies like
JavaScript, HTML, and CSS. It takes care of the hard parts so you can
focus on the core of your application.
Option #2: NW.js (previously known as node-webkit).
Website | GitHub Repo | Releases
Call all Node.js modules directly from DOM/WebWorker and enable a new
way of writing applications with all Web technologies.
Electron and NWJS Pros:
AppJS is officially deprecated
Electron is similar to NW.js but newer, more popular and has a bigger community and updates more frequently. I recommend it.
NWJS always uses the latest Versions of Chromium and Node while Electron takes more time to catch up.
NWJS supports [JavaScript Source Protection][1] by compiling it to V8 native code. Electron does not.
NWJS have a Legacy release for Windows XP and Mac OS X 10.6 support.
Electron and NWJS both use MIT license.
You can compare the contributions to electron with NW.js
Electron and NWJS Cons:
there is no out-of-the-bag run-time solution currently, so you'll have to ship it with your code (~50MB compressed and +100MB uncompressed) or find a way around it.
depending on your app, Electron/NWJS might considered an overkill especially since its startup time is less than ideal, just something to take into account.
no native look, you'll have to create your own UI elements using CSS or using some framework.
Option #3: DeskGap.
Website | GitHub Repo | Releases
DeskGap is a framework for building cross-platform desktop apps with
web technologies (JavaScript, HTML and CSS).
To enable native capabilities while keeping the size down, DeskGap
bundles a Node.js runtime and leaves the HTML rendering to the
operating system‘s webview.
Lightweight since the webview is provided by the operating system.
The API is still quite limited (pretty much a work in progress).
Requires new OS versions.

Apart from the other answers here:
You can take a look at NodeGUI: https://github.com/nodegui/nodegui
NodeGUI is a javascript library for building cross-platform native
desktop applications with JavaScript and CSS like styling. It uses Qt
under the hood and works on Mac, Linux and Windows.
It also has a react based renderer called React NodeGUI which is like React Native but for desktop: https://github.com/nodegui/react-nodegui
Also, its under active development.

I recently discovered https://github.com/yue/yue and I'm having nice experience. It's lightweight, has descent packaging support (and even react/JSX support) and is truly native with decent webview, portable and easy to build target platform's.
Although it seems discontinued I found this project unique, it's really native with options to add a descent webview. I retake some PRs and forked it and I'm adding TypeScript types and documentation since it's really clean/straight forward API, easy to build target platform files. this is my fork although I would like/searching for other users adding missing parts: https://github.com/cancerberoSgx/node-gui . The cons is that it implements node.js event loop so you must use yode (node.js fork) in order for promises and asynchronous code to work well with the GUI code.. m
I wonder if others have experience with this library or forks.

Answer specific to your question may be NodeGui (powered by Qt5, NodeGui-React)
There are many other options. I'm listing a few options below,
electron (Lets you write cross-platform desktop applications using
JavaScript, HTML and CSS, based on Node.js & Chromium)
carlo (Requires Node & Google Chrome to be installed on the system to
run)
NW.js (Similar to electron, provides Source code protection)
DeskGap (bundles a Node.js runtime and leaves the HTML rendering to
the operating system‘s webview)
Proton Native (does the same to desktop that React Native did to
mobile, based on https://github.com/parro-it/libui-node)
For more, you can use my github repo electron-alternatives to pick a cross-platform desktop development option.

Recently also Node-gir may be worth a look: https://github.com/Place1/node-gir
Allows to use Gnome/Glib/Gobject-based libraries from Nodejs. Will allow you to use GTK+.

Related

Where to get a pre-built Chromium to easily do modifications?

Chromium takes too long to get compiled, like 7 hours on a regular powerful desktop. I'm thinking of some where to get a pre-built Chromium, with which I will be able to compile again only some files to re-link to make a new Chromium binary.
Possible to compile just some source code files and re-link (re-link object files)?
It's hard to build Chromium from source but it's every easy to build a new browser based on Chromium.
With GitHub Electron, any app based on it is a real Chromium browser, and developers may create custom UI for their Electron-based browsers.
However, modern browsers would require having servers for storing users' sync data, this might not be easily affordable for 1-man development army to create a new browser for the mass.
Electron app is a pack of Chromium sandbox, and Node.js backend, the 2 communicate thru' IPC as Node.js will be able to access all resources.
GitHub Electron:
https://electronjs.org

Package node.js app as cross-platform executable, not for desktop app

There are a lot of questions on this topic, but they don't seem to distinguish between executables for desktop or server-side apps. I suppose my first question would be: what's the difference? For example, Zeit/pkg says they are a "node.js binary compiler", whereas nwjs (formerly node-webkit) says they are a "an app runtime based on Chromium and node.js".
I tried zeit/pkg and it works great, but have read that there can be performance issues unless it's configured properly. I wanted to make sure I was choosing the right tool and came across nwjs. It seems to do a lot of the same stuff pkg does, but has a larger following, as well as more docs and a robust api. Can I use nwjs as a server-side executable (i.e. not using the desktop feature) the same way I would use pkg?
This answer states that nwjs "is an option, but it really isn't set-up to do a server - client type relationship", but then a comment says "you can launch a server from node-webkit just in the way you launch it in Node.js. It's just that node-webkit provide another way beyond B/S architecture".
So, is nwjs effectively the same as pkg, or fundamentally different?
I realize that there's also Electron, which states "build cross platform desktop apps" and appears similar to nwjs. I'm not trying to get into a Electron vs nwjs debate, but rather desktop vs. server, if there's a difference.
you got most things already, only few clarifications are needed. Reason nw.js / Electron declares itself as for desktop application is, it's core architectural design is intended to integrate node.js with chromium to have UI enables create application does have UI. You can still use part of those framework (node.js side) without initiating visible ui, in that case behaviorwise it'll be similar to plain node.js does. Still there is caveat, like as it tightly integrated with chromium in core already for some cases you should have screen to chromium correctly initiates (or creating virtual buffer as lot of CI does, or etcs).
Also, when your concern is performance, I'd doubt using UI framework for server side work achieves what you desire - while there won't be huge, integration between node to chromium have overhead compare to bare node.js obvioulsy.
Getting back to original question, I feel question itself is somewhat vague. If the intention is truly server side application probably you won't need to package it but correctly deploy node and its dependency modules or packaging it sort of installable manner instead of creating single binary as pkg does.

Lightweight Desktop APP with Node - is that possible?

My current App (WPF in Visual Studio) weighs 2MB.
And now I want to re-create this App with Node and Javascript.
Why? Primary reason is - I want to learn some Javascript (yes, this is My way to learning and please dont give me advices how to learn JS). Secondary reason - I want to use full power of CSS3, while WPF App supports only CSS2.
The problem is Weight. Any example App builded with Electron or NWJS weighs about 115MB!!!
I can understand that Desktop App require Node and Browser to work, but 115MB?!
So my question is - Is there any way to create Lightweight Desktop App with Electron/NWJS (or similar alternative)?
I can accept final weight about 50-60MB.
Electron or NW.js are huge in terms of size and required memory, but there are lightweight alternatives: Libui-node and Positron. Other lightweight platforms not based on node.js are: React-Native, XULRunner and Qt Quick with QML.
I can only speak for Electron, but 115MB sounds about right for a minimal app, the Chromium content library which Electron is based on is an all or nothing sort of thing and takes up a large chunk of that space.

Desktop applications with Meteor.js

The options I've found for creating desktop applications in HTML, CSS, and JavaScript are:
Electron (formerly Atom-Shell)
NW.js (formerly Node-Webkit)
However, there doesn't seem to be any clear implementation for using meteor.js with these.
NW.js
I've seen some other questions of people asking this, but no implementation. Can't even figure out by the answers what I should be trying to put together:
Meteor leaderboard app on node-webkit
Demeteorizer with node-webkit
How can I start a Meteor instance before launching a node-webkit?
This guys actually got it running but doesn't say how: https://stackoverflow.com/questions/25508737/iron-router-routing-fails-on-reload-in-node-webkit
The idea proposed here is interesting—loading the desktop application completely from the web. However, I would like to allow my users to use the application offline.
Electron
There is an actual implementation, meteor-desktop-app, but it has no clear support for Windows. However, the atom-shell does support Windows just as NW.js does.
Has anyone figured out an implementation to allow meteor.js to operate as a desktop application?
If you drop the code from meteor-desktop-app into Electron Starter, you'll get Windows + Mac + Linux for free, as well as a build system you can definitely use for Real Apps.
Check out mongoclient's scaffold directory, it'll lead you to your electron app if you follow the steps from readme.

Is there a way to compile node.js source files? [duplicate]

This question already has answers here:
Is it possible to create desktop applications with node.js? [duplicate]
(5 answers)
Closed 7 years ago.
Is there a way to compile a node.js application?
I maybe very late but you can use "nexe" module that compile nodejs + your script in one executable: https://github.com/crcn/nexe
EDIT 2021: Nexe's latest release is from 2017 and it appears that development has otherwise slowed, so the more-widely-used alternative from Vercel should also be considered these days: pkg
Node.js runs on top of the V8 Javascript engine, which itself optimizes performance by compiling javascript code into native code... so no reason really for compiling then, is there?
https://developers.google.com/v8/design#mach_code
EncloseJS.
You get a fully functional binary without sources.
Native modules also supported. (must be placed in the same folder)
JavaScript code is transformed into native code at compile-time using V8 internal compiler. Hence, your sources are not required to execute the binary, and they are not packaged.
Perfectly optimized native code can be generated only at run-time based on the client's machine. Without that info EncloseJS can generate only "unoptimized" code. It runs about 2x slower than NodeJS.
Also, node.js runtime code is put inside the executable (along with your code) to support node API for your application at run-time.
Use cases:
Make a commercial version of your application without sources.
Make a demo/evaluation/trial version of your app without sources.
Make some kind of self-extracting archive or installer.
Make a closed source GUI application using node-thrust.
No need to install node and npm to deploy the compiled application.
No need to download hundreds of files via npm install to deploy your application. Deploy it as a single independent file.
Put your assets inside the executable to make it even more portable.
Test your app against new node version without installing it.
There was an answer here: Secure distribution of NodeJS applications. Raynos said: V8 allows you to pre-compile JavaScript.
You can use the Closure compiler to compile your javascript.
You can also use CoffeeScript to compile your coffeescript to javascript.
What do you want to achieve with compiling?
The task of compiling arbitrary non-blocking JavaScript down to say, C sounds very daunting.
There really isn't that much speed to be gained by compiling to C or ASM. If you want speed gain offload computation to a C program through a sub process.
Now this may include more than you need (and may not even work for command line applications in a non-graphical environment, I don't know), but there is nw.js.
It's Blink (i.e. Chromium/Webkit) + io.js (i.e. Node.js).
You can use node-webkit-builder to build native executable binaries for Linux, OS X and Windows.
If you want a GUI, that's a huge plus. You can build one with web technologies.
If you don't, specify "node-main" in the package.json (and probably "window": {"show": false} although maybe it works to just have a node-main and not a main)
I haven't tried to use it in exactly this way, just throwing it out there as a possibility. I can say it's certainly not an ideal solution for non-graphical Node.js applications.
javascript does not not have a compiler like for example Java/C(You can compare it more to languages like PHP for example). If you want to write compiled code you should read the section about addons and learn C. Although this is rather complex and I don't think you need to do this but instead just write javascript.

Resources