Drupal's Node.js integration module in localhost.

With Node.js you can add real-time capabilities to Drupal like instant messaging(chat), live update of views or feeds, etc. Here you will find a detailed tutorial on how to install Node.js integration module in localhost in Windows.

 

Install Node.js if not already installed. Click here for detailed information on installing Node.js in Windows.

In this tutorial, it is assumed that Drupal 7 is installed in a directory named “drupal”, and it can be accessed from the browser by visiting “localhost/drupal”. If your configuration is different, Node.js integration module can easily be installed with minor modifications in some of the steps.

 

1) Download the node.js integration module. (Generally, modules are placed inside the “..../sites/all/modules/” directory.

 

2) Open Command Prompt, and change the working directory to the nodejs module directory. You can do that easily by using the following command.

cd “C:\xampp\htdocs\drupal\sites\all\modules\nodejs” if using XAMPP, or

 

cd “C:\wamp\www\drupal\sites\all\modules\nodejs” for WAMPserver.

 

If you are using some other server stack, change the path accordingly.

 

3) Make sure you are connected to internet and the current directory in Command Prompt is “nodejs” as described in the last step.

Type the command shown below and press Enter. NPM(node.js package manager) will read the file “package.json”, and download the required node.js modules like socket.io, request, express, connect, etc. Remember, Node.js has its own module system, it should not be confused with Drupal's module system.

npm install

 

Note: You might have seen somewhere to use “sudo npm install”. “sudo” is used in Unix-like operating systems. You should not use “sudo” in Windows.

npm install command

Wait for the process to complete.

 

Process screenshot.

npm processing required nodejs modules

 

Downloading required files.

npm downloading required files

 

After the process has been completed.

npm install process completed

Keep the Command Prompt window open, we will use it later.

 

4) Enable Nodejs integration, Nodejs Notifications, and Nodejs config modules from the module administration page located at admin/modules.

 

5) Go to admin/config/nodejs/js. Node.js server configuration builder page will open.

 

Most of the default values in this configuration builder will work. See the image below for hint.

nodejs configuration settings

 

In the backend section's "Auth Path" field change the value to “/drupal/nodejs/message”, since drupal is installed in a sub-directory.

Keep the "Debug" checkbox enabled to see message logs in Command Prompt.

nodejs configuration backend

 

Save the configuration.

 

Now, copy the value of the field “Suggested configuration”.

Create a blank JavaScript file named “nodejs.config.js” in the nodejs module folder. Paste the copied value in this file.

 

6) Run the server.js file in the nodejs folder, using the command:

node server.js

 

start node server for drupal

7) Go to admin/config/nodejs/nodejs_notify/broadcast.

You will see the system-wide broadcast notification form. Type subject and message, and click Broadcast.

nodejs system-wide broadcast notification

 

If you look at the terminal(command prompt), you will see some message logs as shown below.

message logs in command prompt

 

This means, Node.js integration module is working correctly.

Hosting for Drupal

McAfee APAC


You might want to contribute to Qoncious.com:




Latest Videos