On Java, Python, Groovy, Grails, Spring, Node.js, Linux, Arduino, ARM, Embedded Devices & Web

  • Recent Posts

    August 2017
    M T W T F S S
    « Jul    
  • Subscribe Options

  • Awards

  • Most Valuable Blogger @ DZone
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 172 other followers

  • Follow MyThinkPond on
  • Blog Stats

    • 364,737 hits
  • General Options

Archive for the ‘Node JS’ Category

How to package your node.js application for deploying it in an offline environment?

Posted by Venkatt Guhesan on October 14, 2016

node2Personally speaking, I prefer to have a self-contained bundle with all the artifacts and modules that might be required to deploy an application (not just Node.js application) in Production. In that way, I know exactly the bits that were installed and nothing more and nothing less. It also eliminates the availability of the NPM modules and network connectivity issues, etc. The following procedure shows you how to create a simple “Hello World” Node.js application with one dependency – Express.js (which has dependency on other modules) and to bundle (pack) it and deploy it to an environment that may not have an internet connection.

Brief Summary:
“bundledDependencies”: [“package-name1”] in the package.js does the trick in combination with “npm pack” and “npm install <Project>.tar.gz

Below is the step-by-step walk-thru.

So let’s get started:
In Development Computer:

Make sure you have Node.js installed and you can verify the installation by running:

$node -v

Now let’s get started on a simple “Hello World” – Node.js project:

Follow the steps outlined here for setting up a simple Hello World using Node.js and Express. In my case, running “npm install express –save” created additional module dependencies on the following:

$npm install express --save
└─┬ express@4.14.0
├─┬ accepts@1.3.3
│ ├─┬ mime-types@2.1.12
│ │ └── mime-db@1.24.0
│ └── negotiator@0.6.1
├── array-flatten@1.1.1
├── content-disposition@0.5.1
├── content-type@1.0.2
├── cookie@0.3.1
├── cookie-signature@1.0.6
├─┬ debug@2.2.0
│ └── ms@0.7.1
├── depd@1.1.0
├── encodeurl@1.0.1
├── escape-html@1.0.3
├── etag@1.7.0
├─┬ finalhandler@0.5.0
│ ├── statuses@1.3.0
│ └── unpipe@1.0.0
├── fresh@0.3.0
├── merge-descriptors@1.0.1
├── methods@1.1.2
├─┬ on-finished@2.3.0
│ └── ee-first@1.1.1
├── parseurl@1.3.1
├── path-to-regexp@0.1.7
├─┬ proxy-addr@1.1.2
│ ├── forwarded@0.1.0
│ └── ipaddr.js@1.1.1
├── qs@6.2.0
├── range-parser@1.2.0
├─┬ send@0.14.1
│ ├── destroy@1.0.4
│ ├─┬ http-errors@1.5.0
│ │ ├── inherits@2.0.1
│ │ └── setprototypeof@1.0.1
│ └── mime@1.3.4
├── serve-static@1.11.1
├─┬ type-is@1.6.13
│ └── media-typer@0.3.0
├── utils-merge@1.0.0
└── vary@1.1.0

Now edit, package.js and add define the bundleDependencies section like so:

  "name": "guhelloproject",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.14.0"
  "bundledDependencies": ["express"]

Let’s create index.js

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');

Test the code locally in development to ensure that it works.

$node index.js
Example app listening on port 3000!
# You should see "Hello World", if you point your browser to http://localhost:3000/

Now for the bundling magic.

$npm pack

In your Production server (which has no internet connection):

  1. Make sure you install Node.js so that the Node executable is available. Verify once again by running “node -v” (as shown above)
  2. Move the “guhelloproject-1.0.0.tgz” file to the Production server.
$npm install guhelloproject-1.0.0.tgz
# This unzips the bundle into a 'node_modules' directory 
$cd cd node_modules/guhelloproject/
$node index.js
Example app listening on port 3000!

Point your browser to http://:3000/ and you should see “hello world”.

Posted in Javascript, Node JS | Tagged: , , | Leave a Comment »

Getting started with vertx ( – an alternative to node.js

Posted by Venkatt Guhesan on November 15, 2012

Article Getting started with vertx ( – an alternative to node.js – has been posted on the new website at:

Posted in Node JS, VertX | Tagged: , , | Leave a Comment »

Getting started with vertx ( – an alternative to node.js

Posted by Venkatt Guhesan on November 15, 2012

Lately there has been a lot of synergy and publicity around node.js (especially if you want to utilize the robust features of a JavaScript language on the server-side). If you are not familiar with this, I would suggest you look at the following link:

Node.js – Event-driven I/O server-side JavaScript environment based on V8.

If you are a Java developer and as you try out the examples, you will notice how this will be a great addition into your infrastructure. But then as you delve deeper, you may notice some of the short comings such as having to support another full stack of package manager (Node uses NPM as it’s package manager) and it has it’s own deployment, unit testing, etc. to support. And then the thought might occur that – what-if I had the same infrastructure available natively in the Java stack??? Would that not solve a lot of the logistical challenges? If your answer is “yes”, then you should look at this library…

VertX from – Effortless asynchronous application development for the modern web and enterprise

The VertX solution is built upon (and requires) a JDK/JRE under the skin. But then because Java support other languages under it’s skin, you can leverage the benefits of languages such as – JavaScript, CoffeeScript, Ruby, Python, Groovy or Java.

According to the VertX website – it says and I quote “Write your application components in JavaScript, CoffeeScript, Ruby, Python, Groovy or Java. Or mix and match several programming languages in a single app.”

Here’s their “Hello-World”:


vertx.createHttpServer().requestHandler(function(req) {
    var file = req.path === '/' ? 'index.html' : req.path;
    req.response.sendFile('webroot/' + file);

As always, you need to evaluate this option to see if this solution fits in your infrastructure and it’s pros and cons.

If you find this article useful, share this with others and/or subscribe to this blog.

Posted in Node JS, VertX | Tagged: , , , | Leave a Comment »