We can place a breakpoint in the server.js file and debug the file just as we debug C# code files.įigure 2: Debugging server.js in Visual StudioĪll variables and objects in the code can also be inspected as seen in Figure 3: It is not a console created by Visual Studio, it is the console installed with Node.js. When the application is running, you will see a console popping up. Run the application now and you will see a “Hello World” on your browser.
It sends Hello World in response to any incoming request. If you check the server.js file, it has a very simple response defined. It defines the port on which the application has to run, contains calls to any middle wares required and defines actions for routes server.js: This file is the starting point for the Node.js application.It is similar to nfig file used with NuGet package.json: This file contains the list of Node.js packages and their versions needed by the project.As we started with an empty project, it doesn’t show anything as of now npm: Displays the node.js packages installed in the project.Once the project is created, observe the structure of the project in the Solution Explorer. If you have installed Node tools for Visual Studio, you must be able to see the Node.js option under JavaScript and a number of project templates for creating Node.js application as shown in Figure 1:įigure 1: Node.js templates in Visual Studio What’s in the template?įrom the list, choose Blank Node.js Web Application and change the name to ‘NodeMovieList’. Open Visual Studio 2012 or 2013 and choose File > New > Project. Once these commands are executed, MongoDB is up and running on your system as a service. Run the command prompt as ‘Run as administrator’, change path to the bin folder of MongoDB on your system and run the following commands:Ĭ:\Mongodb\bin\mongod.exe -config c:\MongoDB\nf -install Change name of the text file as ‘nf’ and paste the following statements in it:įeel free to modify dbpath and logpath as per the path in your system. Now go to the D:\MongoDB\bin folder and create a text file. In the folder named MongoDB, create a folder named ‘data’ and inside this folder, create another folder and name it ‘db’ Once extracted, follow these instructions:
For Mongo DB, you will get a zip file containing a set of binaries.
You just need to download and install the tools. The first three installations are straight forward. Node Tools for Visual Studio can be used with Visual Studio 2012 Web Developer Express, Visual Studio 2013 Web Developer Express, or any paid versions of Visual Studio 2012 or 2013 (Professional, Premium or Ultimate).Īs for the pre-requisites, you must have the following tools installed on your system: You can use any OS that supports Visual Studio 2012 or 2013. I have used Windows 7 64-bit and Visual Studio 2013 Ultimate to develop the sample.
In this article, we will build a Movie list application using Node.js, Express.js, Mongo DB and Angular JS on Visual Studio. Other components can be added as they are needed. It has just the right number of components to start the server. Unlike other server technologies, Node.js doesn’t have a lot of components installed by default. The pipeline of Node.js is very light weight. Once the asynchronous operation (here assuming it is fetching data from a database) completes, the Event loop receives a message about its completion and the result is processed once the event loop is free. Event loop then frees up the thread and responds to any other event that comes in. When it encounters an asynchronous event like fetching data from a database, the operation is performed outside the event loop. Event loop keeps listening to the server events. The server has only one thread to execute all the operations. Node executes every operation as an Event.
Subscribe to this eMagazine for Free and get access to hundreds of free tutorials from experts NET professionals published once every two months. NET Magazine – A Free High Quality Digital Magazine for. This article is published from the DotNetCurry. This makes execution of server, non-blocking. So, they are all executed asynchronously. It assumes that all I/O operations are slow.
Node.js works the same way as JavaScript works on any modern browser. Using Node.js, one can quickly build and run a web application within a few minutes. Built with C++ and JavaScript, Node.js uses V8 (JavaScript engine that comes with Chrome) as its engine to process JavaScript on the server. Node.js is not a JavaScript library it is a platform for creating web applications on the server side, using JavaScript. Ryan Dahl introduced Node.js in his talk at JSConf 2009 and his talk received a standing ovation from the audience.