Installing NodeJS on NetBeans

Currently my favorite IDE for NodeJS is NetBeans. Although there are other excellent IDEs available, nothing beats a free one. Also, as I regularly use NetBeans for PHP it is natural to also use the same for NodeJS as it becomes easier to manage multiple projects in a single IDE. In this post I describe steps to install NodeJS development environment in NetBeans.

Installation

I assume that NodeJS is installed on your system. If not than first install NodeJS and npm before processing further. There are a couple of nodejs plugin available. I like the one by Tim Boudreau, it provides a project type and support for running NodeJS projects and files in the NetBeans IDE. Download the plugin nbm file from timboudreau.com. Make sure you are running the latest version of NetBeans. I’m using version 8.

Go to NetBeans Tools > Plugins > Downloaded menu and click on ‘Add Plugins…’. Select the downloaded nbm file and click install. This will install the nodejs plugin.

Creating a NodeJS project

Now that the plugin is installed create a new NodeJS project. The plugin provides a default ‘Hello World’ project.

netbeans-nodejs

Once a new project is created the IDE should look like below with the ‘Hello World’ program loaded (click for a larger view). Note the libraries automatically being loaded in the ‘libraries’ tree branch.

netbeans-nodejs-ide

Now that the project is created set it as the main project and run the project. The first time it will probably ask you for the nodejs executable path. Once the project is started we can now check that the ‘Hello World’ program is running in the browser.

http://localhost:9080/

Once the nodejs program is running you have to manually stop all the running instances. To stop the nodejs instances click on NetBeans ‘Run > Stop Build/Run‘ menu. Note that as the above example starts a nodejs server, we require that we stop that manually, however nodejs programs that do not act as a server do not require to be killed. A simple example is given below. This will execute using the nodejs executable and immediately exit.

var dns = require('dns');
 
dns.lookup('www.google.com', function onLookup(err, addresses, family) {
  console.log('addresses:', addresses);
});

You can also run individual nodejs files by clicking on the content menu.

netbeans-nodejs-ide3



2 thoughts on “Installing NodeJS on NetBeans

Comments are closed.