Cross-platform package a node.js app - node.js

So I have a Node.js app that runs on the command line.
I created a very simple GUI window in Qt which calls the Node.js command line program.
I can package up the Qt GUI with Qt Installer Framework.
It works great.
But it only works on my machine...
I need to:
install node.js on the user's computer. I don't want to rely on the "system" version of node.js and would prefer to have a "sandboxed" version of node.js somewhere in my application's directory. Also, user may not have any compilers installed...
run npm and install a couple of packages to the user's computer
needs to run on Mac/Windows/Linux
Am I being unrealistic here?

Related

ng commands always return "This: not found" on Windows WSL 2

I'm new on Angular, and I'm not able to run ng commands on WSL version 2.
I installed Angular CLI running:
npm install -g #angular/cli
After that I created a new npm project folder and a package.json running:
npm init
But every ng command returns:
/mnt/c/Users/xxxxxx/AppData/Roaming/npm/node_modules/node/bin/node: 1: This: not found`
I installed Node.js on Windows with an executable (so under PowerShell, everything works as expected). Am I wrong with this?
I installed Node.js on Windows with an executable before (so on PowerShell works), am I wrong with this?
Not, necessarily "wrong", but it's likely part of the problem. But you are certainly correct to question it and provide it as a critical detail in your post!
While WSL can launch Windows executables, keep in mind that those Windows executables (npm in this case) typically only understand Windows paths, processes, environment variables, etc.
npm on the Windows version of Node is a bit unusual, thought. It provides a Bash shell script, which is actually what is being called when you run npm under WSL. That shell script was originally designed for Cygwin and Git Bash, but I see that Node recently added checks in it for WSL as well. Before that, even (the Windows version of) npm itself would have issues under WSL.
But regardless of whether they've fixed npm to work under WSL, then you run into the next level of issues since Angular hasn't modified ng to detect when it is running under WSL.
Without having dug into the source code, ng is going to see that it is running under the Windows version of Node and try to use Windows tools and paths. In my test under WSL (using the Windows version of Node/npm), what seems to happen is that ng new project tries to start CMD.exe. Since it is running under the Windows version of Node, it naturally assumes that CMD.exe is available.
And it is, but starting CMD.exe from inside WSL will attempt to start in a UNC path (\\wsl$\<distroname>\path\to\current\project\dir or \\wsl.localhost\...). CMD doesn't support UNC paths, so it defaults to the Windows directory itself, and I get:
EPERM: operation not permitted, mkdir 'C:\Windows\project'
While you are getting a different error, to be sure, it's almost certainly related to this root issue.
To make a long story longer, see my advice in the question, How to organize programming languages and libraries in WSL and Windows 10.
To summarize it, when using development tools, either:
Use the Windows version of the toolchain (editor, commandline, SDK, tools, etc.)
Or use all-Linux versions of the toolchain.
Also, though, be careful with Node specifically. You can install:
The Windows version of Node for when you are using Windows tools
The Linux version of Node for when you are using WSL tools
But when you are running in WSL/Linux, make sure that the Linux version of npm and node appear first in the path, before the Windows version. This is, again, because of the fact that the Windows version provides that shell script. If the Windows version comes before the Linux version in your Linux PATH, then you will continue to have issues since the Windows npm will get called under WSL (as it is now).

How to run an Electron .exe app on Linux?

I'm trying to run an application build with Electron on Linux. They app maker offers an .exe installation file. So I figured I'd install it in WINE, but I seem to be missing something the app needs to run.
Since the install is an .exe, do I need WINE? And if I need WINE, what do I need to install to make the app work? I have tried two Electron apps, both only downloadable as a .exe install file.
Electron adds os native calls, so .exe files usually do not work. WINE is not able to emulate all of those calls, so if it isn't working for you, then you are out of luck I guess. Look for apps that offer linux versions, like https://www.electronjs.org/apps/camunda-modeler. If you have access to the repository, chances are they build it using electron-builder. You can just build it yourself with the command electron-builder build --linux in most cases

Can I compile/package a Node-Webkit (NW.js) app into an exe for windows and a version for Linux?

I've looked on the Node-Webkit site and it appears to say that I can make an application with HTML5 and compile it for Windows, Linux of Mac so it will run without the need for the user to install Node.js separately. However, when I try their sample apps (e.g. https://github.com/leanote/desktop-app found on the official NW.js page: https://github.com/nwjs/nw.js/wiki/List-of-apps-and-companies-using-nw.js ), the ".exe" file does not run the app (on either Win 7 or XP). It just opens a simple browser window with the address "nw:blank" and a gray page says "NW.JS" and does nothing.
Can these apps be packaged and run without requiring the user to install node.js?
https://github.com/leanote/desktop-app 's nw folder is not the distribute leanote app, it's just the NW. You must build the desktop-app. The README has written How to build it, How to develop it
You can download the distributed version via: https://github.com/leanote/desktop-app/releases
You might try... node-webkit-builder ... which is supposed to build a huge .EXE file which is self-contained for you. Otherwise, the instructions for distributing... how to package and distribute, see Step 2b.

TideSDK app on Mac

I developed an app via TideSDK on OSX. I have a .app and It is working on OSX. However, you know it cannot work on linux or windows. I want to run my app on linux or windows. How can I do that?
In short, you package for each platform. As you are aware mac apps do not run on Windows and it is the same with TideSDK since you are creating something native for each platform.
TideSDK must be installed on each platform to create an executable and bundle for it.
To generate an installer for each system, you need to run commands on each system (windows / linux 32bit / linux 64bit) using tidebuilder.py on the command line.
We will have more to speak about concerning packaging quite soon that will make the task of building and distributing your apps easier. Stay tuned for updates !!

File-based installation of Node.js

I'm temporarily stuck on a Windows machine on which I have no administrator privileges. I would like to get node.js "installed" in a directory without using an installer, which requires elevation. On the node.js site, I don't see this distribution option.
Is anyone aware of a file-based (zip, self-extracting exe, etc) download that I can use to run node.js without using an installer on a Windows machine? Is there a way to run the installer without administrator elevation?
OK, it turns out that the EXE download for Windows is all that node.js needs to run. I had thought that that was an exe for doing an installation. Just running the downloaded .exe works.

Resources