How did I solve the “TypeError: Cannot read property ‘prototype’ of undefined” (NodeJS-ExpressJS-Redis)?

After installing Redis in our server as outlined in my last post on installation of Redis in CentOS 6.5, it was time for me to setup ExpressJS-NodeJS-Redis(Session Store) setup for the webapp that I am working on.

Everthing seemed perfect until I attempted to start the node server using the command: node app.js. I was welcomed with the below error message which highlighted the fact that connect-redis npm module had falied to connect to my Redis server.

var redis_store = require('connect-redis')(express);
TypeError: Cannot read property 'prototype' of undefined
    at module.exports (/home/nodeuser/node_modules/connect-redis/lib/connect-redis.js:96:41)
    at repl:1:43
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

Upon scouting Internet for answers, the solution posted by Andrei Karpushonak at StackOverflow post titled, ‘RedisStore – TypeError: Cannot read property ‘prototype’ of undefined‘ solved the issue.

Since I have used expressjs version 3.4.8 in my application, I had to use a compatible connect-redis npm. As per the StackOverflow post, the version mentioned by Andrei Karpushonak is 1.4.7.

I installed connect-redis-1.4.7 using the command: npm install --save connect-redis@1.4.7 and the webapp started without reporting any failures.


How did I solve Redis Installation failure in CentOS 6.5?

I decided to use Redis1 as a session store for my ExpressJS2-NodeJS3-Couchbase4 application.

The first step towards this was to download, compile and install Redis5.

The compressed tar.gz redis package is available at I downloaded this package and extracted it in /opt directory. The installation page5 suggests executing the make command. In my case, the command failed with the below error:

make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/opt/redis-2.8.9/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/opt/redis-2.8.9/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/opt/redis-2.8.9/src'
make: *** [all] Error 2

The solution for the above problem was to install gcc and make using the command: yum install gcc make.

Upon completion of the installation, I triggered, make once more. This time around, the make command failed and the errors indicated that few header files were missing.

make[1]: Entering directory `/opt/redis-2.8.9/src'
    CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/opt/redis-2.8.9/src'
make: *** [all] Error 2

After scouting Internet for solutions67, I finally ended up with the below solution8.

cd /opt/redis-2.8.9/deps
cd ..

Compiling the contents of the deps (dependencies) folder before the issuing, make in the /opt/redis-2.8.9/ solved the problem.

If the make is successful, the redis-server binary would end up in the src folder (in my case, it would be /opt/redis-2.8.9/src). The server can be started using:


Its time to start creating a start-up script (daemon process) and configure it to start during the runlevels 2, 3, 4 and 5.


Cassandra: How to fix, ‘Fatal exception during initialization org.apache.cassandra.config. ConfigurationException: Saved cluster name Test Cluster != configured name…’?

I was trying to set up a five node Cassandra cluster in Ubuntu 12.04. Upon a successful installation of Cassandra following the steps outlined at here, and updating /etc/cassandra/cassandra.yaml on all the nodes based on the information provided in the, ‘Initializing a Multi-Node or Multi-Data Center Cluster‘ section of the Cassandra documentation, I was frustrated to find that Cassandra failed to start.

Upon analyzing the logs (/var/log/cassandra/system.log), it was evident that Cassandra did not start due to an exception, "Fatal exception during initialization org.apache.cassandra.config. ConfigurationException: Saved cluster name Test Cluster != configured name...".

Continue reading “Cassandra: How to fix, ‘Fatal exception during initialization org.apache.cassandra.config. ConfigurationException: Saved cluster name Test Cluster != configured name…’?”

Installation of psycopg2 fails within virtualenv folder in Ubuntu 12.04 – how do I fix this?

Recently, when I attempted to install the PostgreSQL adapter for Python ( psycopg2 ), in a virtualenv folder in Ubuntu 12.04, it failed. Upon attempting several solutions, I have boiled down to a fix that worked and decided to document it in an effort to help others resolve similar issue.

# Install the PostgreSQL development files (if you haven't installed them already).
sudo apt-get install postgresql-server-dev-all

# Install other required libraries
sudo apt-get install libpq-dev python-dev

# Attempt installation of psycopg2 within the virtualenv folder.
source /bin/activate
pip install psycopg2

# The installation of psycopg2 should proceed smoothly by now. If it still fails, try installing the postgresql-client libraries.
sudo apt-get install postgresql-client-common

# Attempt installation of psycopg2 again and hopefully it should work without issues.


How to backup a remote PostgreSQL db and restore it locally?

This article lists the commands to dump a remote PostgreSQL database in a local file and then restore it on the localhost PostgreSQL server running.

# Please note: The below commands worked for me. It may or may not work for you.

# Please use it at your own risk. # Create a database dump of the the remote DB. pg_dump -h -Fc -o -U remote-postgresql-user remote-db-name > mydatabase.dump # Example: pg_dump -h -Fc -o -U postgres mydatabase > mydatabase.dump # Restore the db dump as a local PostgreSQL database. # Note that I have assumed that you have already installed and configured PostgreSQL

# in your local machine. sudo -u postgres pg_restore -C mydatabase.dump

For a details of the command line options supported by pg_dump and pg_restore, please visit and respectively.


How to install Cassandra in Ubuntu Server 12.04?

Installation of Cassandra in the Ubuntu Server 12.04 can be performed in multiple ways. In this article, I will focus on utilizing the ‘apt-get’ command line utility to install ‘Cassandra’. This information is also documented at the ‘Cassanda Wiki’.

Please note that its recommended to have ‘Oracle JDK at-least version 6’ installed in the machine before installing Cassandra.

Step 1: Add the required repositories.

sudo echo "deb 11x main" >> /etc/apt/sources.list;
sudo echo "deb-src 11x main" >> /etc/apt/sources.list

Step 2: Update.

Continue reading “How to install Cassandra in Ubuntu Server 12.04?”

How to fix the Django error displayed when loading Twissandra for the first time?

Twissandra is a beautiful example project that can be used to learn the features of Cassandra. Its maintained by ‘Tyler Thobbs’. Please see for more details on the Twissandra project.

This article attempts to provide a solution for the Django error that is displayed when you complete all the steps listed at the Twissandra GitHub Readme document and attempt to visit the Twissandra site for first time. When I came across this issue for the firs time, a through research on the solution led me to the fix posted at :Tod (Play Cassandra).

Error reported by the web page:

Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"

One of the possible solution:

Continue reading “How to fix the Django error displayed when loading Twissandra for the first time?”