Templates by BIGtheme NET

How to setup node.js project in eclipse

In this article, I will show how to setup Node.js development environment
in eclipse. How to create Node.js and Node.js Express projects in eclipse.
How to create, compile and run the project. Project structure overview.

How to setup Node.js project in Eclipse :

If you are not having eclipse IDE, you can download latest eclipse from eclipse

Start your eclipse(command is “eclipse -clean” or double click on eclipse icon) and
browse the url eclipse_tool_for_NodeJS.
Drag-and-drop of install image install on Eclipse main toolbar.

Check and confirm the eclipse features and accept the license and click Finish button.


How to create Node.js Express Project :

In eclipse IDE, Go to File -> New -> Node.js Express Project, and provide project
name “helloworld” and click on Finish.


How to Run project in eclipse :

Right click on App.js -> Run As -> Node Application.


You can see the message in console as “Express server listening on port 3000”, indicating
that server is started with port 3000.

Browse with the URL, http://localhost:3000/

Node.js request flow :

Once we run the app.js file, we mentioned in app.js file as given.

var express = require('express')
  , routes = require('./routes')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');

1) Whenever you run first time, Node is going to register events,
In this case express, routes(sub module), users(sub module), http and path.

2) Once this app.js code is executed, node goes to request loop and continuously checking
is the request is any one of express, routes(sub module), users(sub module), http and path or not.

3) As soon as HTTP request event comes, going to triggered that event and
run callback re-load and call the corresponding routing.

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));

Here we have two routing points defined for HTTP request event,

app.get('/', routes.index);
app.get('/users', user.list);

If you send request like,

1) http://localhost:3000/ – first routing point will be executed.
(routes/index.js file will be executed and print the message).


exports.index = function(req, res){
  res.render('index', { title: 'Express' });


2) http://localhost:3000/users – second routing point will be executed.
(routes/user.js file will be executed and print the message)


exports.list = function(req, res){
  res.send("respond with a resource");


Flow Diagram is :

Project structure overview :

This is the top line project view,

1) JavaScript resources – contains all default JavaScript libraries.

2) node_modules – contains all node.js dependent modules.

3) public – Contains files such as css files

4) routes – we can define our own routing rules here.

5) views – contains all view files.

6) package.json – contains project name, version information.

  "name": "helloworld",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  "dependencies": {
    "express": "3.2.6",
    "jade": "*"

You can Download complete project,
Here helloworld

*** Venkat – Happy leaning ****