Node.js JXcore packaging
Node.js is an open source, cross-platform runtime environment for server-side and web applications.
JXcore is a Node.js distribution that supports multi-threading. It can run directly and safely in multi-threads without making any changes to your existing code.
But our article is mainly to teach you about the packaging function of JXcore.
JXcore installation
Download the JXcore installation package and decompress it. The jx binary file command is provided in the decompressed directory. Next, we will mainly use this command.
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. Window platform download: <a href="%3Ca%20href=.html" https:="" raw.githubusercontent.com="" jxcore="" jxcore -release="" master="" 0311="" jx_win64v8.zip"="">Download(Windows x64 (V8))" targte="_blank">Download,
2、Linux/ OSX installation command:
$ curl http://jxcore.com/xil.sh | bash
If you have insufficient permissions, you can use the following command:
curl http://jxcore.com/xil.sh | sudo bash
If the above steps are performed correctly, use the following command, and the version number information will be output:
$ jx --version v0.10.32
Package code
For example, our Node.js project contains the following files, where 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 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
If the above command is executed successfully, the following two files will be generated:
index.jxp This is a middleware file that contains complete project information that needs to be compiled.
index.jx This is a binary file with complete package information that can be run on the client.
Load JX file
We use the jx command to package the 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 features, you can refer to the official website: http://jxcore.com/.