nodejs

Node.js

Node.js is an open-source and cross-platform JavaScript runtime environment. Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser. V8 is the JavaScript engine i.e. it parses and executes JavaScript code.

Nodejs
Nodejs

Node.js helps the developers to create the server side code along with the client side code without using any other additional languages.

Node.js provides a set of asynchronous I/O primitives in its standard library, libraries in Node.js are written using non-blocking paradigms.

Node.js

ECMAScript standards and ECMAScript versions can be used according to the preference of the developer.

Node.js is a server side environment and is designed to increase the scalability of the web applications and to provide dynamic web page.  It’s run time environment is designed to process the incoming request using the event loop structure. It process the request using single threaded Just like other programming languages it also includes Variables, Types, Classes, Functions, Loops, Arrays, expressions. In addition Strict mode, arrow functions are also added.

Npm

Node Package Manager(NPM) is the default package manager for the JavaScript runtime environment Node.js. It consists of a command line client, also called npm.

Modules

Node.js has different types of Core modules and also allows to create Local Modules according to the need of the developer and application. Examples for core modules are http, url, path, util. File system and its operations are performed using “fs” module. After creating the local module we need to export it. The object module.export is used to export the module. The modules need to be loaded using require() function.

Node.js Frameworks and Tools

A framework is a collection of various libraries and tools which is used to create the software application. It includes other frameworks, extend the properties and functionalities to increase the productivity.

Dependencies

Node package manager is represented with the command “npm” it is used to install the dependencies.

Example:

> npm install json –save

> npm install errorhandler –save

> npm install logger –save

Just like other programming languages it also includes Variables, Types, Classes, Functions, Loops, Arrays, expressions. In addition Strict mode, arrow functions are also  added .

 

Database

Node.js supports both relational database or NoSql database.

Examples :

for relational database  – MySQL, MS SQL SERVER, SQLite

for NoSQL database – MongoDB,  Couch DB

Node.js

Node.js File System

Node.js includes fs module to access the files. The fs module is responsible for all the asynchronous or synchronous file I/O operations.

Different methods are used to perform the file operations. Some examples are readFile(), writeFile(), appendFile(), unlinkFile(), other parameters and flags are used according to the need.

 

Debug Node.js Application

In Node.js we need to do debugging in the command line. Debugging process can be done as a step by step process.

We need to start the command with the keyword “inspect” to start the debugging process.

 

Node.js Web Server

 

The web server will handle all the http requests for the web application. In Node.js we can create our own web server which will handle HTTP requests asynchronously.

The http module is used to create the web server, then the createServer() method is used, next callback function will be used handle the request and response in the web server. Call listen will handle all incoming requests of the web server.

Web console

A Web console is a tool which is mainly used to log information associated with a web page like: network requests, JavaScript, security errors, warnings, CSS etc. It enables us to interact with a web page by executing JavaScript expression in the contents of the page.

Node.js console is an object and is used to print different levels of messages.

 

Leave a Comment

Your email address will not be published. Required fields are marked *