Is it possible to compile a JS application + NodeJS interpreter into a single executable file?

Can I compile a JS application and NodeJS interpreter into a single executable file for distribution?

+7
javascript compilation distribution
source share
3 answers

you will need a linux box with git and python, and then an ugly solution:

$ git clone git://github.com/ry/node.git $ cd node $ vim src/node.js # add your code to end before "process.loop();" $ ./configure $ make $ sudo make install $ node 
+6
source share

Can I compile a JS application and NodeJS interpreter into a single executable file for distribution?

This may seem obvious, but here I take it upon myself.

"A single executable file for distribution" sounds just like the installer ...

The installer will contain or be able to extract online js scripts and compiled node.js. It will unpack everything and create a script in /etc/init.d/ to start and stop the server.

If all your clients are on the same distribution (for example, Debian), I will just create a package for the appropriate packaging tool (for example, apt) and let the batch tool handle everything.

All clients have different distributions, you can see autopackage .

+1
source share

If your goal is to run javascript, you could create a simple C or C ++ wrapper program that would create an interpreter and evaluate your JS. If you need one file, the js source can be included as a string constant.

When you compile a wrapper program, you want to statically link it to node and the rest of your dependency tree. Instead of depending on the shared libraries in the system, static linking copies the routines your project depends on into a compiled binary.

How you do it will depend on your environment.

+1
source share

All Articles