felipefss
felipefss

Reputation: 129

How to run an executable on client-side using Node.js?

Is there a way to call an external program on client side and "talk" to it?

For example, if I have a Node.js serverving an AngularJS or any other framework, I want the user to press a button on the browser and a previously installed program on client-side starts to run and send back to the client some messages...

Can I achieve that?

Upvotes: 3

Views: 3797

Answers (4)

SimperT
SimperT

Reputation: 2867

This is certainty possible in many different ways.

One sort is using node webkit.

Another,a NPM package called Edge. This is sort of like a bridge between node a .net. Or more specifically node and a clr process. You can execute c# statements and load assemblies in a clr process and interact with it in javascript via node and Edge.

https://github.com/tjanczuk/edge

Upvotes: 1

Rax Wunter
Rax Wunter

Reputation: 2767

Browsers cannot run executables on the local machine without explicit configuration as such behaviour would violate security restrictions.

Node.js can do anything that is permitted by the environment (e.g user permissions) in which it is run. See: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

Upvotes: 4

georgeawg
georgeawg

Reputation: 48948

Consider using Native Client

Native Client is a sandbox for running compiled C and C++ code in the browser efficiently and securely, independent of the user’s operating system. Portable Native Client extends that technology with architecture independence, letting developers compile their code once to run in any website and on any architecture with ahead-of-time (AOT) translation.

In short, Native Client brings the performance and low-level control of native code to modern web browsers, without sacrificing the security and portability of the web.

https://developer.chrome.com/native-client

Upvotes: 1

oriaj
oriaj

Reputation: 788

I think that the better form to do that is using API REST, you can create your server API in node JS for example and use AngularJS to consume that services in the browser and JAVA or .NET for the Desktop app

the following is a simple Example using Node and Angular

Upvotes: 0

Related Questions