Think. Build. Salesforce Solutions.

Salesforce Consulting Services across Salesforce Clouds & Across App Lifecycles



By |2020-07-21T08:38:56+00:00December 4th, 2015|Tags: , , |

What is Node?

This blog will introduce you to the NODE. I will take you through Node and its environment set up for developing your first application. Node is an open-source, cross-platform runtime environment for executing the JavaScript code. For Node, you must be acquainted with JavaScript, HTML, and CSS and also have some familiarity with web applications and the MVC concept. Its built on the Google V8 JavaScript engine and V8 compiles JavaScript code to native machine code.

node js introduction

Before Node, JavaScript was only executed in browsers. In 2009 Ryan Dahl used an open-source Google V8 JavaScript engine to build Node as a runtime environment for JavaScript outside a browser.
So using Node it is possible to use JavaScript as a server-side language.
By using Node we can develop the MVC based web applications. With Node, however, you use JavaScript everywhere, on the server-side as well as on the client-side.

For more information about Node follow the link below:

Setting up the Environment

I took the reference of the given link
For developing a Node-based application there are a few tools, which we have to install in our system. Here is a list of some basic tools which we need for Node application.

Install Text editor to build your code. Here is a list of text editor which you can install on your system.
Or you can use your Notepad editor.

Install MongoDB
After installing Mongo either you can run it from command prompt or window service.

Install Node by going to the given link you will get NPM (Node Package Manager) on your machine. By using NPM we can download packages/modules in our applications.

Install Express Generator
Express Generator is a Node module that we use to scaffold (platform) an application. To install Express Generator open a new Command Prompt and run the given command

Npm install -g express-generator

Create a platform of your project which you want to develop using Node.
Enter the given command on command prompt after installing Express Generator,
Express project Name
Example: – express hello here hello is my project name.
Now open your project in your favorite text editor and the directory structure of your application will be like this:-
node js introduction
introduction to node js
introduction to node js
Public is where we store public assets of our website, such as Javascript files, stylesheets, images, etc.

Routes defines an endpoint in your application where you receive requests.

node js introduction
View includes the view files for your application. Express supports many popular template engines such as Jade, Html, EJS, and Handlebars, etc. Jade is the default template engine for Node.

App.js is the entry point to your application. Its where your application is defined and configured. This is the controller of your application.

node js introduction
Package.json this includes application metadata and identifies application dependencies. Here you will see your package.json structure:-
node js introduction
Here we will specify name and the version of our application as well as its dependencies.

Install Dependencies

To install the dependencies, go to terminal or command prompt and run the following commands:

introduction to node js
Npm install
To know more about the packages follow the link below:

node_module is the folder in your application directory where all modules will be stored.
node js introduction
Install Nodemon
To install Nodemon follow the given command

Npm install nodemon -g

When you start a Node application, a basic web server starts on port 3000 and accepts incoming requests. If you make any changes in your application, you need to restart your application server so this is a time taking process to start the server after every alteration. So in order to overcome we use Nodemon, which is another Node module that automatically restarts your web server whenever it detects any change in your source files.

Install Monk

Monk is a Node module for reading and writing documents in MongoDB
To install monk follow the given command
Npm install monk save

How to run your application?

For running this basic application run the following command on your project directory on command prompt
Go to project by using
Cd hello
Then enter the command to run application


Nodemon will start your web server on port 3000, as shown in the above image.
Now launch your browser and navigate the given link:

Here is your first express application.

node js introduction
For more information about Node you can refer to the link below:–net-20496

Anil Singh

Leave A Comment