Node.js JXcore Packaging
Node.js is an open-source, cross-platform runtime environment for server-side and network applications.
JXcore is a Node.js distribution that supports multithreading; it requires virtually no changes to your existing code to run it safely in multiple threads.
This article mainly introduces the packaging feature of JXcore.
JXcore Installation
Download the JXcore installation package and extract it. The extracted directory provides the jx binary command, which we will mainly use below.
Step 1: Download
Download the JXcore installation package https://github.com/jxcore/jxcore-release; you need to download the installation package according to your own system environment.
1. Download for the Windows platform:Download(Windows x64 (V8))。
2. Linux/OSX installation commands:
$ curl https://raw.githubusercontent.com/jxcore/jxcore/master/tools/jx_install.sh | bash
If you do not have sufficient permissions, you can 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, using the following command will output version information:
$ jx --version
v0.10.32
Packaging Code
For example, our Node.js project contains the following files, of which index.js is 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 Use the following command to package the above project and specify index.js as the main file of the Node.js project:
$ jx package index.js index
If the above command executes successfully, the following two files are generated:
-
index.jxp This is a middleware file containing the complete project information to be compiled.
-
index.jx This is a binary file with complete package information that can run on the client.
Loading a JX File
Running 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
More references for JXcore installation:https://github.com/jxcore/jxcore/blob/master/doc/INSTALLATION.md。
For more JXcore features, you can refer to the official website:https://github.com/jxcore/jxcore。