Tools and versions
This how-to was tested using the following tools and versions:Windows 10
Netbeans 8.1
Java JDK 1.80_91
Node.js v6.2.2 (includes npm 3.9.5)
And the current (06-July-2016) quickstart Angular2 for Javascript, available at https://angular.io/docs/js/latest/quickstart.htm
How-to
Install all the tools:
If you don't already, download and install the tools.Java JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Node.js : https://nodejs.org/en/download/releases/
Netbeans: https://netbeans.org/community/releases/81/Configure Netbeans
Start Netbeans and go to the "Options" windows. You will find this under "Tools".Fill out all the settings in this window:
- "Node Path "must point to the directory where you installed Nodejs and must contain node.exe
- After filling out the Node Path click on the download button, this should download the correct Source files. However I this appears to be optional.
- npm Path will also point to the directory where Nodejs is installed, but it must contain npm.cmd.
- "Express generator" can be left empty, the Angular quickstart does not seem to use this.
Create the project
Start the new project wizard:
Select as category "HTML5/Javascript" and as project "HTML5/JS Application with Node.js"
Give the project the name used by the quickstart app: "angular2-quickstart".
You do not need to enable Express.

And the only file that needs to be created is the "package.json".

You have now created your project, but there is one last thing to do before you can start following the Angular quickstart. Netbeans created a map "public", which at this point only contain a index.html file. Netbeans expects you to add the public files in this map but the map is not used in the Angular tutorial. So when you create the css, html and js files of the tutorial in this map and run the project as it is now you will get the error "Cannot GET /" when opening the site in your browser. There appear to be two option to fix this:
- Create a file called "bs-config.json" in the root folder containing the following.
{
"server": { "baseDir": "./public",
"routes": {
"/node_modules": "node_modules"
}
}
}
This tells BrowserSync to look in the public map and to reroute any requests for the Node.js files to the submap containing these files. The tutorial files can then be created in the map called "Site Root" or in the public map under "Sources".
- The second option is to remove the public folder and change the project properties to use no "Site Root Folder". The project properties window can be reached by right clicking the project and select properties.

The tutorial files can then be created in folder "Site Root / Sources".
Netbeans appears to prefer the first method, it will show a warning when the root directory is the same as the "Site Root Folder".
Set-up is ready: time to follow the Angular2 quickstart
At this point the project is set up and you should be able to complete the tutorial in Netbeans 8.1
- After changing the package.json file Netbeans will show a popup asking if you want to download the dependency's. If you want to download the dependency's at a later time you can always right click on the project and select "npm install" there.

Known problems
Public map is called public_html:You probably selected a "HTML/JS application" when choosing the type of project. Recreate the project as a "HTML/JS application with Node.js" project or create a bs-config.json file in the root folder containing the following:
{
"server": { "baseDir": "./public_html",
"routes": {
"/node_modules": "node_modules"
}
}
}
The Netbeans windows in the screenshots do not look (exactly) like your Netbeans windows / menu items are named different:
You are probably using a different version of Netbeans, they do seem to change the IDE (options window) a lot in every version. If you run into a lot of problems configuring Netbeans then try using the same version I am using, or to find a tutorial for your version of Netbeans.




Is there any simple quick start Netbeans project with all the required configuration for NodeJS and Angular 2 ?
ReplyDeleteAnd I think the "Public folder" is better and easier to understand when combining the Angular2 and NodeJS
I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Netbeans, kindly contact us http://www.maxmunus.com/contact
ReplyDeleteMaxMunus Offer World Class Virtual Instructor led training on Netbeans. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us.
Nitesh Kumar
MaxMunus
E-mail: nitesh@maxmunus.com
Skype id: nitesh_maxmunus
Ph:(+91) 8553912023
http://www.maxmunus.com/
I prefer to use Codelobster for Angular development.
ReplyDeleteThanks for a very useful guide. How can I debug a node.js app using netbeans?
ReplyDeleteWhen I start via: -> nmp Scripts -> dev
I can get navigate to the app via http://localhost:3000
However, if I start the app via: -> Debug
I cannot navigate to the app; http://localhost:3000 gives a connection refused.
Any help appreciated.