Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Learn About Packaging in NodeJS with 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.

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.

Step 3: – Choose the installation directory as C:/JXcore and Next to proceed for installation.

Step 4: – Select the component which you want to install. In this article, we are going to select “V8 x64” as component. Click Next.

Step 5: – Select start menu folder.

Step6: – Click the checkbox, to add application directory to environment PATH variable. Click next.

Step 7: – Click on the install button to 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.

C:\odesk\Abhishek Thakur\NodeJS\MyNPMApplication\hello-world-server.js
C:\odesk\Abhishek Thakur\NodeJS\MyNPMApplication\node_modules
C:\odesk\Abhishek Thakur\NodeJS\MyNPMApplication\images
C:\odesk\Abhishek Thakur\NodeJS\MyNPMApplication\scripts

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.

C:\odesk\Abhishek Thakur\NodeJS\MyNPMApplication>jx package hello-world-server.js hello-world-server
Processing the folder..
JXP project file (hello-world-server.jxp) is ready.

preparing the JX file..
Compiling hello-world-server 1.0
adding script hello-world-server.js
adding script node_modules\accepts\index.js
adding script node_modules\accepts\package.json
adding script node_modules\array-flatten\array-flatten.js
adding script node_modules\array-flatten\package.json
adding script node_modules\content-disposition\index.js
adding script node_modules\content-disposition\package.json
adding script node_modules\content-type\index.js
adding script node_modules\content-type\package.json
adding script node_modules\cookie\index.js
adding script node_modules\cookie\package.json
adding script node_modules\cookie-signature\index.js
adding script node_modules\cookie-signature\package.json
adding script node_modules\debug\bower.json
adding script node_modules\debug\browser.js
adding script node_modules\debug\component.json
adding script node_modules\debug\debug.js
adding script node_modules\debug\node.js
adding script node_modules\debug\package.json
adding script node_modules\depd\index.js
adding script node_modules\depd\lib\browser\index.js
adding script node_modules\depd\lib\compat\buffer-concat.js
adding script node_modules\depd\lib\compat\callsite-tostring.js
adding script node_modules\depd\lib\compat\event-listener-count.js
adding script node_modules\depd\lib\compat\index.js
adding script node_modules\depd\package.json
adding script node_modules\destroy\index.js
adding script node_modules\destroy\package.json
adding script node_modules\ee-first\index.js
adding script node_modules\ee-first\package.json
adding script node_modules\encodeurl\index.js
adding script node_modules\encodeurl\package.json
adding script node_modules\escape-html\index.js
adding script node_modules\escape-html\package.json
adding script node_modules\etag\index.js
adding script node_modules\etag\package.json
adding script node_modules\express\index.js
adding script node_modules\express\lib\application.js
adding script node_modules\express\lib\express.js
adding script node_modules\express\lib\middleware\init.js
adding script node_modules\express\lib\middleware\query.js
adding script node_modules\express\lib\request.js
adding script node_modules\express\lib\response.js
adding script node_modules\express\lib\router\index.js
adding script node_modules\express\lib\router\layer.js
adding script node_modules\express\lib\router\route.js
adding script node_modules\express\lib\utils.js
adding script node_modules\express\lib\view.js
adding script node_modules\express\package.json
adding script node_modules\finalhandler\index.js
adding script node_modules\finalhandler\package.json
adding script node_modules\forwarded\index.js
adding script node_modules\forwarded\package.json
adding script node_modules\fresh\index.js
adding script node_modules\fresh\package.json
adding script node_modules\http-errors\index.js
adding script node_modules\http-errors\package.json
adding script node_modules\inherits\inherits.js
adding script node_modules\inherits\inherits_browser.js
adding script node_modules\inherits\package.json
adding script node_modules\inherits\test.js
adding script node_modules\ipaddr.js\bower.json
adding script node_modules\ipaddr.js\ipaddr.min.js
adding script node_modules\ipaddr.js\lib\ipaddr.js
adding script node_modules\ipaddr.js\package.json
adding script node_modules\media-typer\index.js
adding script node_modules\media-typer\package.json
adding script node_modules\merge-descriptors\index.js
adding script node_modules\merge-descriptors\package.json
adding script node_modules\methods\index.js
adding script node_modules\methods\package.json
adding script node_modules\mime\build\build.js
adding script node_modules\mime\build\test.js
adding script node_modules\mime\cli.js
adding script node_modules\mime\mime.js
adding script node_modules\mime\package.json
adding script node_modules\mime\types.json
adding script node_modules\mime-db\db.json
adding script node_modules\mime-db\index.js
adding script node_modules\mime-db\package.json
adding script node_modules\mime-types\index.js
adding script node_modules\mime-types\package.json
adding script node_modules\ms\index.js
adding script node_modules\ms\package.json
adding script node_modules\negotiator\index.js
adding script node_modules\negotiator\lib\charset.js
adding script node_modules\negotiator\lib\encoding.js
adding script node_modules\negotiator\lib\language.js
adding script node_modules\negotiator\lib\mediaType.js
adding script node_modules\negotiator\package.json
adding script node_modules\on-finished\index.js
adding script node_modules\on-finished\package.json
adding script node_modules\parseurl\index.js
adding script node_modules\parseurl\package.json
adding script node_modules\path-to-regexp\index.js
adding script node_modules\path-to-regexp\package.json
adding script node_modules\proxy-addr\index.js
adding script node_modules\proxy-addr\package.json
adding script node_modules\qs\.jscs.json
adding script node_modules\qs\dist\qs.js
adding script node_modules\qs\lib\index.js
adding script node_modules\qs\lib\parse.js
adding script node_modules\qs\lib\stringify.js
adding script node_modules\qs\lib\utils.js
adding script node_modules\qs\package.json
adding script node_modules\qs\test\index.js
adding script node_modules\qs\test\parse.js
adding script node_modules\qs\test\stringify.js
adding script node_modules\qs\test\utils.js
adding script node_modules\range-parser\index.js
adding script node_modules\range-parser\package.json
adding script node_modules\send\index.js
adding script node_modules\send\package.json
adding script node_modules\serve-static\index.js
adding script node_modules\serve-static\package.json
adding script node_modules\setprototypeof\index.js
adding script node_modules\setprototypeof\package.json
adding script node_modules\statuses\codes.json
adding script node_modules\statuses\index.js
adding script node_modules\statuses\package.json
adding script node_modules\type-is\index.js
adding script node_modules\type-is\package.json
adding script node_modules\unpipe\index.js
adding script node_modules\unpipe\package.json
adding script node_modules\utils-merge\index.js
adding script node_modules\utils-merge\package.json
adding script node_modules\vary\index.js
adding script node_modules\vary\package.json
adding script package.json
adding asset .jshintrc
adding asset .project
adding asset .sublime-project
adding asset .tern-project
adding asset build.gradle
adding asset node_modules\accepts\HISTORY.md
adding asset node_modules\accepts\LICENSE
adding asset node_modules\accepts\README.md
adding asset node_modules\array-flatten\LICENSE
adding asset node_modules\array-flatten\README.md
adding asset node_modules\content-disposition\HISTORY.md
adding asset node_modules\content-disposition\LICENSE
adding asset node_modules\content-disposition\README.md
adding asset node_modules\content-type\HISTORY.md
adding asset node_modules\content-type\LICENSE
adding asset node_modules\content-type\README.md
adding asset node_modules\cookie\HISTORY.md
adding asset node_modules\cookie\LICENSE
adding asset node_modules\cookie\README.md
adding asset node_modules\cookie-signature\.npmignore
adding asset node_modules\cookie-signature\History.md
adding asset node_modules\cookie-signature\Readme.md
adding asset node_modules\debug\.jshintrc
adding asset node_modules\debug\.npmignore
adding asset node_modules\debug\History.md
adding asset node_modules\debug\Makefile
adding asset node_modules\debug\Readme.md
adding asset node_modules\depd\History.md
adding asset node_modules\depd\LICENSE
adding asset node_modules\depd\Readme.md
adding asset node_modules\destroy\LICENSE
adding asset node_modules\destroy\README.md
adding asset node_modules\ee-first\LICENSE
adding asset node_modules\ee-first\README.md
adding asset node_modules\encodeurl\HISTORY.md
adding asset node_modules\encodeurl\LICENSE
adding asset node_modules\encodeurl\README.md
adding asset node_modules\escape-html\LICENSE
adding asset node_modules\escape-html\Readme.md
adding asset node_modules\etag\HISTORY.md
adding asset node_modules\etag\LICENSE
adding asset node_modules\etag\README.md
adding asset node_modules\express\History.md
adding asset node_modules\express\LICENSE
adding asset node_modules\express\Readme.md
adding asset node_modules\finalhandler\HISTORY.md
adding asset node_modules\finalhandler\LICENSE
adding asset node_modules\finalhandler\README.md
adding asset node_modules\forwarded\HISTORY.md
adding asset node_modules\forwarded\LICENSE
adding asset node_modules\forwarded\README.md
adding asset node_modules\fresh\HISTORY.md
adding asset node_modules\fresh\LICENSE
adding asset node_modules\fresh\README.md
adding asset node_modules\http-errors\HISTORY.md
adding asset node_modules\http-errors\LICENSE
adding asset node_modules\http-errors\README.md
adding asset node_modules\inherits\LICENSE
adding asset node_modules\inherits\README.md
adding asset node_modules\ipaddr.js\.npmignore
adding asset node_modules\ipaddr.js\.travis.yml
adding asset node_modules\ipaddr.js\Cakefile
adding asset node_modules\ipaddr.js\LICENSE
adding asset node_modules\ipaddr.js\README.md
adding asset node_modules\ipaddr.js\src\ipaddr.coffee
adding asset node_modules\ipaddr.js\test\ipaddr.test.coffee
adding asset node_modules\media-typer\HISTORY.md
adding asset node_modules\media-typer\LICENSE
adding asset node_modules\media-typer\README.md
adding asset node_modules\merge-descriptors\HISTORY.md
adding asset node_modules\merge-descriptors\LICENSE
adding asset node_modules\merge-descriptors\README.md
adding asset node_modules\methods\HISTORY.md
adding asset node_modules\methods\LICENSE
adding asset node_modules\methods\README.md
adding asset node_modules\mime\.npmignore
adding asset node_modules\mime\LICENSE
adding asset node_modules\mime\README.md
adding asset node_modules\mime-db\HISTORY.md
adding asset node_modules\mime-db\LICENSE
adding asset node_modules\mime-db\README.md
adding asset node_modules\mime-types\HISTORY.md
adding asset node_modules\mime-types\LICENSE
adding asset node_modules\mime-types\README.md
adding asset node_modules\ms\.npmignore
adding asset node_modules\ms\History.md
adding asset node_modules\ms\LICENSE
adding asset node_modules\ms\README.md
adding asset node_modules\negotiator\HISTORY.md
adding asset node_modules\negotiator\LICENSE
adding asset node_modules\negotiator\README.md
adding asset node_modules\on-finished\HISTORY.md
adding asset node_modules\on-finished\LICENSE
adding asset node_modules\on-finished\README.md
adding asset node_modules\parseurl\HISTORY.md
adding asset node_modules\parseurl\LICENSE
adding asset node_modules\parseurl\README.md
adding asset node_modules\path-to-regexp\History.md
adding asset node_modules\path-to-regexp\LICENSE
adding asset node_modules\path-to-regexp\Readme.md
adding asset node_modules\proxy-addr\HISTORY.md
adding asset node_modules\proxy-addr\LICENSE
adding asset node_modules\proxy-addr\README.md
adding asset node_modules\qs\.eslintignore
adding asset node_modules\qs\.eslintrc
adding asset node_modules\qs\CHANGELOG.md
adding asset node_modules\qs\CONTRIBUTING.md
adding asset node_modules\qs\LICENSE
adding asset node_modules\range-parser\HISTORY.md
adding asset node_modules\range-parser\LICENSE
adding asset node_modules\range-parser\README.md
adding asset node_modules\send\HISTORY.md
adding asset node_modules\send\LICENSE
adding asset node_modules\send\README.md
adding asset node_modules\serve-static\HISTORY.md
adding asset node_modules\serve-static\LICENSE
adding asset node_modules\serve-static\README.md
adding asset node_modules\setprototypeof\LICENSE
adding asset node_modules\setprototypeof\README.md
adding asset node_modules\statuses\HISTORY.md
adding asset node_modules\statuses\LICENSE
adding asset node_modules\statuses\README.md
adding asset node_modules\type-is\HISTORY.md
adding asset node_modules\type-is\LICENSE
adding asset node_modules\type-is\README.md
adding asset node_modules\unpipe\HISTORY.md
adding asset node_modules\unpipe\LICENSE
adding asset node_modules\unpipe\README.md
adding asset node_modules\utils-merge\.travis.yml
adding asset node_modules\utils-merge\LICENSE
adding asset node_modules\utils-merge\README.md
adding asset node_modules\vary\HISTORY.md
adding asset node_modules\vary\LICENSE
adding asset node_modules\vary\README.md
adding asset README.md
[OK] compiled file is ready (hello-world-server.jx)

C:\odesk\Abhishek Thakur\NodeJS\MyNPMApplication>

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.

jx hello-world-server.jx command_line_arguments


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.

The post Learn About Packaging in NodeJS with JXcore appeared first on Eduonix.com | Blog.



This post first appeared on How And When Should You Use HBase NoSQL DB, please read the originial post: here

Share the post

Learn About Packaging in NodeJS with JXcore

×

Subscribe to How And When Should You Use Hbase Nosql Db

Get updates delivered right to your inbox!

Thank you for your subscription

×