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
First Download and install latest version of Node.js on your machine if you haven’t already.
Update:
Node Eclipse is no longer supported and is not working for new versions of Eclipse.
The next best option is to use https://code.visualstudio.com/ for any node and front-end development.
But you can still use Node Eclipse in older version of Eclipse and it works great.
Download Node Eclipse from https://nodeclipse.github.io/updates/
Or
For your existing eclipse IDE
1. Start Eclipse (RECOMMENDED WAY: A BIT QUICKER).
2. Drag and drop into a running Eclipse (menu area) to install Nodeclipse.
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, click Confirm and accept the licence then click on finish.
4. Installation will take a while and then 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
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:
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.
In order to run the project as localhost we need to add a run configuration.
From Eclipse menu select: Run > 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
Explaining Project Structure
If you are familiar with a Model View Controller (MVC) project structure, this is very similar to it.
- 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 š
Hi – is there a way to configure eclipse so to use nodemon or something similar so I don’t have to restart the Express server whenever I make a change? Thank you for this helpful tutorial!
How to run a frisby script using the RUN AS option … just like running a JAVA class … ?
In the run configurations i cant find app.js when searching. any one has an idea?
Me too… You fix this problem ?
app.js mean that file that you actually want to execute
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.
Hi there, you need to run your node.js app as a service.
please have a look at my tutorial part 3 & 4: http://d14heuw5xvy8tb.cloudfront.net/setup-node-js-web-server-on-amazon-ec2/
I have done this on Ubuntu but the process is similar with minor difference.
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
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.
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)
but which is the best for node.js eclipse IDE or intellij idea IDE
Thanx for help
Thank you it lot of help…
This is very useful!
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.
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
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.
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 š
Nice one Thanks
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)
})
Yes, one needs to add this piece of code for this to work. thanks anonymous.
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]
As I mentioned in post the latest version can be installed using http://www.nodeclipse.org/updates/
the first url might be out of date now.
if that didn’t work too try http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=1520853
in the install window
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.
Thank you very much really helpful
Great tutorial for beginners. Thanks a lot.
Excellent tutorial for beginners. Helped me alot in Inital stages.
Great tutorial for beginners. Thanks a lot.
Nice, Good to kick off!
Great tuto but, do we have to install all the modules we need globally ?
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.
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.
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?
See my reply above – you have to set NODE_PATH in your run config
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?
Can you share the error message here? There could be many possibilities