Easy Tutorial
❮ Nodejs Event Loop Nodejs Callback ❯

Node.js JXcore Packaging

Node.js is an open-source, cross-platform runtime environment for server-side and networking applications.

JXcore is a multi-threaded distribution of Node.js that allows you to run your existing code in a thread-safe manner with minimal changes.

This article aims to introduce the packaging feature of JXcore.


JXcore Installation

Download the JXcore installation package, unzip it, and you will find the jx binary command in the unzipped directory, which we will primarily use.

Step 1: Download

Download the JXcore installation package from https://github.com/jxcore/jxcore-release, and choose the package according to your system environment.

  1. Windows platform download: Download(Windows x64 (V8)).

  2. Linux/OSX installation command:

    $ curl https://raw.githubusercontent.com/jxcore/jxcore/master/tools/jx_install.sh | bash
    

If you lack permissions, use the following command:

$ curl https://raw.githubusercontent.com/jxcore/jxcore/master/tools/jx_install.sh | sudo bash

If the above steps are performed correctly, the following command will output the version information:

$ jx --version
v0.10.32

Package Code

For example, our Node.js project includes the following files, with index.js being the main file:

drwxr-xr-x  2 root root  4096 Nov 13 12:42 images
-rwxr-xr-x  1 root root 30457 Mar  6 12:19 index.htm
-rwxr-xr-x  1 root root 30452 Mar  1 12:54 index.js
drwxr-xr-x 23 root root  4096 Jan 15 03:48 node_modules
drwxr-xr-x  2 root root  4096 Mar 21 06:10 scripts
drwxr-xr-x  2 root root  4096 Feb 15 11:56 style

Next, we use the jx command to package the above project and specify index.js as the main file of the Node.js project:

$ jx package index.js index

Upon successful execution of the above command, two files will be generated:


Load JX File

To run a Node.js project:

$ node index.js command_line_arguments

After compiling with JXcore, we can use the following command to execute the generated jx binary file:

$ jx index.jx command_line_arguments

For more JXcore installation references: https://github.com/jxcore/jxcore/blob/master/doc/INSTALLATION.md.

For more JXcore features, refer to the official website: https://github.com/jxcore/jxcore.

❮ Nodejs Event Loop Nodejs Callback ❯