Learn About Packaging in NodeJS with JXcore

0
2712
Jxcore

Jxcore

In this article, we are going to discuss about Jxcore, which is an open source project. JXcore project in Node.js helps to introduce an exclusive feature for packaging and encryption of source files along with its important assets into JX packages. JXcore packaging is applicable to an organization, which has its medium to large size business applications built on Node.js. Usually, these large sized applications have many files within the application source code. Any project with a large number of files is very difficult to maintain but with JXcore, we can pack these files together all into a single file in order to simplify the distribution. Further in this article, we will discuss on this overall process starting from the installation of the JXcore project.

How to install JXcore?
JXcore is very easy to install. Given below are the step-by-step instructions on how to install JXcore on your computer system.
Step 1: – You can download the JXcore package from https://github.com/jxcore/jxcore-release depending on the type of operating system and machine architecture which you are currently using.
JXcore package
In this article, we have downloaded a package for windows 64-bit architecture machine.

Downloaded file name is jx_winsetup.zip

Step 2: – We can now unzip the downloaded file jx_winsetup.zip and copy the jx binary into C:/JXcore on your computer system setup. Click on the installer to start the installation as shown below.
Setup - Jxcore
Step 3: – Choose the installation directory as C:/JXcore and Next to proceed for installation.
Choose the installation directory
Step 4: – Select the component which you want to install. In this article, we are going to select “V8 x64” as component. Click Next.
Select the component
Step 5: – Select start menu folder.
Select start menu folder
Step6: – Click the checkbox, to add application directory to environment PATH variable. Click next.
Select Additional Task
Step 7: – Click on the install button to complete the installation of JXcore.complete the installation of JXcore
This completes the installation of JXcore. Now open the command line to check the version of the JXcore by executing the following simple command.

jx --version
How to package Code using JXcore?
Consider a Node.js project which you might have created before (say MyNPMApplication). It has the following directories, such that you have kept all your files including Node.js, main files, hello-world-server.js, and all the modules installed locally as shown below.

You can package the above entire project files into a single file by using JXcore. All you have to do is that, simply navigate inside this directory and execute the following jx command. Here, the hello-world-server.js is the entry file for our Node.js project.

We can choose any package name for JX file (here we have used ‘hello-world-server’). The above command will pack the entire Node.js project and create the following two files.
• File hello-world-server.jxp: – This is an intermediate file that contains the entire project detail which is required to compile the project.
• File hello-world-server.jx: – This is the binary file which have the complete package. It is ready to be shipped to your client or to be deployed into your production environment.

How to launch JX File?
After compilation of the Node.js application package using JXcore, it can be launched by executing the following command on the command line.

hello-world-server
Source code for Packaging in Node.js

Conclusion: –
In this article, we discussed the installation, packaging and launching JXcore module to generate a single file for a large project application built in Node.js.

LEAVE A REPLY

Please enter your comment!
Please enter your name here