Creating a Standalone Node.js WEBAPP - javascript

Please note that I'm looking to create a webapp, not an executable or native application.
I have created a node.js application using express, react, and webpack. I'd like to be able to package and deploy the website and have it run on other computers (no internet connection) but still in a browser. Just by opening an index.html file in Chrome or something similar without having node installed or running any local servers. Just open the index in Chrome and away it goes. Is this possible? How can I go about doing so?

The requirements are interesting, but it might be difficult to run node.js if they don't have it installed. Definitely sounds like something you want to package, maybe in a self-containing binary.
Take a look at Electron. It powers Atom and supports node.js. Also comes with a bundled Chromium browser.

Related

How to deploy Javascript app that runs from command line?

I have a simple CLI application written in Javascript using Node that is for internal use by a small team. It runs in the Linux terminal as a CLI app. The app consists of a single ".js" file and requires a few Node packages. The problem I face now is how to deploy it to our internal team using a simple method that fits with our routine process of keeping end user computers updated.
Our app needs to be installed once per workstation / laptop and to be available to all users on that computer. Any user should be able to open a terminal and enter the command to run the app.
It seems a lot of people have discussed using Javascript for shell programming, but this issue of deploying the completed app is not widely discussed. I have not found anything on the topic. So far I have been recommended solutions that are appropriate for either development environments or web servers.
This app is not a web app and it is not deployed on a server. It needs to run offline. I am also not asking about developing or maintaining the app on a development workstation.
The installation process should ideally be as about simple as installing a shell script in /usr/local/bin and setting permissions so all permitted users on a computer can run it. We are looking for an installation method like this:
copy the Javascript file only once to each computer (to a location on the $PATH) and make sure the Node packages are available globally on that computer.
I specifically want to avoid having to do an npm install for each user account on each computer.
I also want to avoid having to update Node packages for each user account on each computer.
A developer will keep the app updated so it is always compatible with the latest version of the Node packages, and all computers it is deployed on will always have the latest versions of those packages installed.
One specific problem I encountered is discussed here, but the answers assume a different set of requirements (such as the need for "multiple applications running on different package versions").
For those requirements, if the actual problem is solving the EACCESS error (you should edit the question to include that information), then you should look at the permissions of all directories, and make sure that the user account that manages node packages on each computer has correct permissions.
One way to do that is to give /usr/local a special group, set the sticky bit with chmod (see man chmod), and use chgrp -R on the existing tree.
Then make the installing account a member of that group, and don't use sudo for npm install -g.
(Never using sudo for installations into /usr/local has the additional advantage that you can't accidentally install something somewhere else, for example because you didn't set paths in this local package source correctly.)
We are using these two approaches for similar deployments:
the programs live on a specific network mount. All users can run the same package from there. The developer only updates this package. No copying to local machines.
we use a simple deployment script which runs on all machines on logon. It pushes and copies the latest version to the local machine.

What is the role of Node.js in React-Native?

I'm trying to understand the development process of React-Native, so I've found information about Metro, And then I've read/watch this Metro video):
Metro is the development platform for React Native and it does that by
exposing an HTTP server so clients, in this case, emulators can
communicate with it and it also exposes a Websocket server so it can
push updates into the clients.
The docs talk about the "React Native Packager" (now called Metro, according to the video) which runs on port 8081, so that is the HTTP server that starts when we type react-native run-android for example?
Regarding the Websocket I still need to read more.
The documentation says we're running our JavaScript code in two environments, depending if we're in debug mode or not, which I understood. But this article confused me a little bit, says:
No. 4 You Code Does Not Run on Node.JS: The JavaScript runtime you’ve got is ether JavaScriptCore (non-debug) or V8 (debug). Even
though you can use NPM and a node server is running on the background,
your code does not actually run on Node.JS. So you won’t be able to
use of the Node.JS packages. A typical example is jsonwebtoken, which
uses NodeJS’s crypto module.
And, then I've read things like:
React Native uses Node.js, a JavaScript runtime, to build your
JavaScript code.
Node.js is a server-side JavaScript runtime environment. React
Native ships with some tools that are written for Node.js.
Node.js is an open source platform built on Chrome's JavaScript
runtime; it offers a way to easily build fast, scalable
programs. Node.js allows you to run JavaScript in Terminal, and helps
create modules.
In this article, it says:
Download node.js from nodejs.org. This JavaScript runtime gives you
access to npm, which is a convenient tool created by the node.js
project that you can use to manage open source packages. Make sure
that you download the latest LTS (Long Term Support) version of
node.js. Also included with this download is a development server
called the Metro bundler, which provides live updates when debugging.
So:
The role of Node.js in RN is to only access npm and manage the packages? and is Metro is includes in Node.js? Am I missing/confusing something? Thank you.
There are four types of JavaScript you'll write in todays environments:
1) Clientside browser JavaScript:
That's what gets sent to webbrowsers when they visit your webpage, it then gets executed in the browser at the clientside. As you want the JS to load fast and run on all kinds of browsers, you usually use transpilers to turn the modern ESnext you write into a minified version with better support.
2) Clientside native JavaScript:
Most devices do have a native JS runtime, therefore you can ship JS files with your Android / iOS / Desktop application and then start them there. These engines also support adding hooks from JavaScript into your native code, that's how React Native does provide it's APIs.
3) Serverside NodeJS JavaScript:
NodeJS is a runtime you'll use to run servers.
4) Buildscripts running on NodeJS:
You can use JavaScript to generate JavaScript files. That's how you bundle the files for (1) and (2) (maybe also (3)).
Now metro is a serverside buildscript (on NodeJS) that you can use to either a) start a server that serves your JS as a webpage (1 & 3), or b) that bundles your JS in a native App that you can install on your device (2).
The role of Node.js in RN is to only access npm and manage the packages?
No. metro is itself a package that you then run on NodeJS.

Compiling python packages for electron js

So my question is pretty straight forward. I am using Electron js and python to create a desktop application. The problem I have though is that the application would make use of a couple of python packages and selenium. Is there a way to compile those packages in such a way that the user of the desktop app wont need to install python and the packages on their system to use the desktop app?
You could use py2exe and py2app for Windows and Mac. Linux and MacOS should already have python installed though. These allow you to make executable python applications that do not require python to be installed on the users' computer.
I hope this helped :)

App to access file system and run in browser

I am willing to make a portable app using HTML CSS JS and similar languages that doesn't need any installation and can be accessed via a browser.
The app should be able to access the file system and create, write and delete files.
The required files will be on the local machine.
I have tried
Applets but the performance is too inconsistent and depends on browsers.
I have also tried using electron but the end result needs installation (correct me if I am wrong)
I am open to all suggestions
Electron's apps can be portable. Copy the electron build resulted folder into a pendrive and execute the main .exe file from there. Everything should work

Package node.js in Cocoa/OSX app

OK, here's what:
I don't want to write an OSX app in node.js - the app is almost complete and 100% in Objective-C/Cocoa
I don't want to bridge Objective-C and node.js
I want to be able to execute a js/node.js script, regardless of whether the user has already pre-installed the node.js binary
So, is there any known way? What would you suggest?
I found a couple resources that look as though they have had success embedding node in a Mac App. I haven't tried them yet, but they look promising.
How to add NodeJS and node_modules to a Mac App
https://ind.ie/labs/blog/gracefully-running-node-as-an-nstask-in-cocoa/
Have a look at zeit/pkg: Package your Node.js project into an executable.

Categories

Resources