How to setup Node.js project in Eclipse

Step by step tutorial on how to setup your Node.js project in Eclipse IDE

This tutorial shows you how to setup a professional web application project using Node.js and Express framework in a Eclipse IDE

Prerequisites

First Download and install Node.js on your machine if you haven’t already.

Then install Express framework using Node.js Command Line:
$ npm install -g express
Now Download Eclipse IDE for EE Developers, the Juno package from here. It can be any other Eclipse packages but I recommend using Eclipse EE Juno packages as it comes with many web development packages.

Eclipse IDE

Eclipse IDE

Install Node Eclipse

Update: node eclipse has a new eclipse IDE called Enide, prepackaged with all necessary softwares.

download Enide from¬†http://www.nodeclipse.org/enide/studio/2014/ and come back for rest of tutorial here to learn how to use it ūüôā

1. Drag and drop  into a running Eclipse (menu area) to install Nodeclipse. Or from Eclipse Menu click Help > Install new softwares

Eclipse Help Menu

Eclipse Help Menu

2.  Enter the update site URL into the Work with text Box: http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=1520853

UPDATE: for the latest version read this page http://www.nodeclipse.org/updates/ 

¬†Uncheck “Contact all updates site during install to find required software”¬†to make installation quicker.

InstallingNodeEclipse

InstallingNodeEclipse

You should see centre box filled with the list of plugins, first three are essential and the rest are optional. Select the appropriate and click next.

3. Review features and accept the licence.

4. You will be ask if you would like to restart Eclipse, click Restart Now.

5. After Eclipse restarts switch to Node perspective: menu > windows > open perspective > other and select Node perspective.

Creating a new Node Project

from Eclipse menu select: file > new > Node Express Project

newNodeProject

newNodeProject

Choose a name and location for your project and select a template for your your HTML files. You have two options of Jade template or ejs template. I recommend ejs but it is totally up to you. If you don’t have experience about these templates read more here:

EJS Template                 Jade Template

Select your template and click finish.

You should see Eclipse starts to add required library for everything shown in console panel as well as a nice structured Node.js app under Project Explorer panel.

Node.js App in Eclipse

Node.js App in Eclipse

In order to run the project as localhost we need to add a run configuration.

From Eclipse menu select: Run > Run Configurations

runConfigurations

run Configurations

Select Node Applications from Left side list and click on ‘add new configuration’ icon.

you should see the right side settings appears. Click on search and search for app.js which is our Node application in this project then click run.

On the console you should see a message like: Express server listening on port 3000

Now you can see your web app running on localhost port 3000

congratulations, you have your Node.js app running on: http://localhost:3000

Node Express App

Node Express App

Explaining Project Structure

If you are familiar with a Model View Controller (MVC) project structure, this is very similar to it.

Node Project Structure

Node Project Structure

  • Looking at the project explorer panel, from the top we have JavaScript resources folder. This is where all JavaScript libraries default to Eclipse is located.
  • Then we have public folder. This is where all the public files such as css and JavaScript files that anyone can access are located.
  • Next folder is ‘routes’. This is where you implement your routing system with their own functionalities.
  • Next is ‘Views’ folder where all the view files are located. Depending on your template system you choose when creating the new project it can be ejs file or jade files.
  • Then we have our core Node.js application functionalities inside the app.js file. This is the file that we run in order to run the applications.
  • Finally we have the package.json file which is our standard Node.js file for managing all the packages and libraries.

I hope this was useful. In next tutorial I will show you guys how to use this project and build a complex Node.js web app that is responsive to all devices using the famous twitter bootstrap.

Any question please leave a comment ūüôā

Author: Ali Shirzad

Share This Post On

35 Comments

  1. How to run a frisby script using the RUN AS option … just like running a JAVA class … ?

    Post a Reply
  2. In the run configurations i cant find app.js when searching. any one has an idea?

    Post a Reply
  3. Hi,
    I have made simple hello world node js app using node eclipse. Now I want to deploy it on the server. My operating system is Centos 6. Please let me know if you have any solution for the same. Thanks in advance.

    Post a Reply
  4. I have installed Express Node eclipse and after creating express node.js express project, I am unable to see bin folder which it has to generate by default. If any one knows let me know … I am new to using it

    Thanks
    Vinod

    Post a Reply
  5. In Enide Studio 2014 with Express 4.x.x, I need to right-click on /bin/ww -> Run As -> Node Application to start the server.

    Post a Reply
    • Window -> Preferences -> Node Eclipse
      Uncheck “find node on PATH….”

      and add node.js path ( My Ubuntu path was /home/bala/.nvm/versions/node/v7.8.0/bin/node)

      Post a Reply
  6. but which is the best for node.js eclipse IDE or intellij idea IDE

    Post a Reply
  7. Thank you it lot of help…

    Post a Reply
  8. Hi, please excuse my newbie question but when you created a new project, why did you choose Node Express project instead of Node.js project? Thank you.

    Post a Reply
    • Express is a framework built on top of node.js. express has lots of different libraries that you can use to extend the functionality of node.js. so the difference is one has express framework and other is pure node js project. There are more information on express js website

      Post a Reply
      • Thank you for reply.
        On another note, have you had experience pushing a Express Node.js project onto Bluemix? If so, can you share how you achieved that? Thanks.

        Post a Reply
        • I have some knowledge about the IBM Bluemix. I will write a detailed tutorial on deploying Node.js to Bluemix and AWS in next a few days that might help you ūüôā

          Post a Reply
  9. for any reason, i had to add the server manually … no idea why

    app.get(‘/’, function (req, res) {
    res.send(‘Hello World!’)
    })

    var server = app.listen(3000, function () {

    var host = server.address().address
    var port = server.address().port

    console.log(‘Example app listening at http://%s:%s‘, host, port)

    })

    Post a Reply
    • Yes, one needs to add this piece of code for this to work. thanks anonymous.

      Post a Reply
  10. When I’m trying to install the new software from http://dl.bintray.com/nodeclipse/nodeclipse/0.8.0/ it says :

    Cannot complete the install because one or more required items could not be found.
    Software being installed: ShellEd 2.0.3 (net.sourceforge.shelled.feature.group 2.0.3)
    Missing requirement: ShellEd Core Plug-in 2.0.0.201307080909 (net.sourceforge.shelled.core 2.0.0.201307080909) requires ‘bundle org.eclipse.dltk.core [4.0.0,6.0.0)’ but it could not be found
    Cannot satisfy dependency:
    From: ShellEd 2.0.3 (net.sourceforge.shelled.feature.group 2.0.3)
    To: net.sourceforge.shelled.core [2.0.0.201307080909]

    Post a Reply
  11. Hi, Great post. I am able to do everything but when I run my configuration i see below.

    In the console: New_configuration [node application] Node.js Process
    In the debug: Node.js Process

    Pl help.

    Post a Reply
  12. Thank you very much really helpful

    Post a Reply
  13. Great tutorial for beginners. Thanks a lot.

    Post a Reply
    • Excellent tutorial for beginners. Helped me alot in Inital stages.

      Post a Reply
  14. Great tutorial for beginners. Thanks a lot.

    Post a Reply
  15. Great tuto but, do we have to install all the modules we need globally ?

    Post a Reply
    • Hi Patrice, you have always the option to install the packages locally in your project folder with $ npm install express or globally using $ npm install -g express commands. but when it comes to deploying to the cloud you have to make sure you have configured your package.json file to include all necessery packages.

      Post a Reply
      • To get it to find the globals on my Mac, I had to this:

        Run As … -> Run Configurations -> Environment Tab
        NODE_PATH=/usr/local/lib/node_modules.

        Post a Reply
  16. Thanks for the tutorial. I am trying to use other modules that I have installed using ‘npm -g install’, eg. ‘npm -g install esprima’.
    While I see the modules listed when typing ‘npm -g ls’ from the console, when I ‘requiring’ them from within app.js using, e.g., esp = require(‘esprima’) I get a “Error: Cannot find module ‘esprima'”: do I need to setup some path in the configuration?

    Post a Reply
    • See my reply above – you have to set NODE_PATH in your run config

      Post a Reply
  17. Great tutorial. My only problem is when I attempt to connect to local host following the instructions outlined in this post it doesn’t work. It says in my console. Do you know what is happening?

    Post a Reply

Trackbacks/Pingbacks

  1. Rachelle Taylor, Business Consultant, Internet Marketing Specialist, SEO, Website Design, Social Media, Lead Generation & Sales Closing Strategies - How to make a responsive Node.js Express website using Bootstrap - […] the¬†previous tutorial¬†by Tech PRD on setting up a Node.js project using Eclipse IDE which can incredibly fast track our…
  2. Rachelle Taylor, Business Consultant, Internet Marketing Specialist, SEO, Website Design, Social Media, Lead Generation & Sales - How To Setup Node.js Project In Eclipse - […] This tutorial was written and created by Ali Shirzad Visit his website Here¬† […]
  3. How to develop a responsive Node.js Express website using Bootstrap TECHPRD - […] How to setup Node.js project in Eclipse […]

leave a comment

%d bloggers like this: