Introduction to Node.js for beginners

Taneesha Ayeshmanthi
3 min readMar 19, 2021

What is Node.js?

Node.js was introduced in 2009 by Ryan Dahl. It is an open-source server-side run time environment. It runs the v8 JavaScript engine. Node.js runs in a single process, without creating a new thread.

It provides a rich library of various JavaScript modules.

Node.js = Runtime Environment + JavaScript Library

Node.js used to build different types of applications like command-line application, web application, real-time chat application, REST API server. But it is not suitable for use for CPU-intensive applications. However, Node.js mainly used in web servers, similar to PHP, java. eBay, General Electric, GoDaddy, Microsoft, PayPal, Wikipins, PayPal, and yahoo are a few companies that are using Node.js.

Features of Node.js

Here we discuss the important features of Node.js.

  1. Very Fast- Node.js library is very fast in code execution because of Google Chrome's V8.
  2. Asynchronous and Event-Driven- Asynchronous means the server can respond to multiple requests at a time. Server not stop or block any API request and respond to all when the response to send accordingly. It means a Node.js based server never waits for an API to return data.
  3. Single-Threaded but Highly Scalable- Node.js use for single-threaded programs. It provides service to a large number of requests than traditional servers. Example Apache HTTP server.
  4. License- Node.js released under the MIT license.

Concepts

The following shows the important parts of Node.js.

  • Debugger
  • Modules
  • Streaming
  • Global
  • Console
  • Buffer
  • Callbacks
  • Crypto
  • Error Handling

Environment Setup

We can refer to all installation instructions for Node.js using the official site:https://nodejs.org. You need the following two software available on your computer,

  1. Text Editor

This use to type your program. Example of the editor's Windows notepad, Brief, Epsilon, EMACS, and vim. Here Notepad used in windows, vim, or vi can be used in windows as well as Linux or UNIX.

The file you're created using your editor know as the source file and that file contains program source code. That source files for Node.js are named using the extension “.js”.

2.The Node.js runtime

The source file where the source code is written is simply javascript. Node.js distribution comes under binary installable for Linux, Mac OS X, SunOS and Windows operating system with 32-bit and 64-bit x86 processor architectures.

Node.js get started

Here we try to display “Hello Medium” in a web browser.

create a file name called “myFirstApp.js”

start command-line interface writes node myFirstApp.js and hit enter.

Now your computer works as a server.

Then, start your internet browser and type in the address = http://localhost:8080

Node.js Modules

Modules are the same as the javascript libraries. To include a module using require() function with the name of the module.

Now the application has access to the HTTP module, able to create a server.

Node.js File System

The Node.js file system help to work with the file system o your computer. To include the file system module we use require() method.

File system modules,

  • Read file
  • create file
  • update file
  • Rename file
  • delete file

Conclusion

In this article, I cover some basic concepts of Node.js for beginners. If you are interested in Node.js follow the following links to see the official documentation and get more information.

Node.js official web site: https://nodejs.org

Intro to Node.js: https://nodejs.dev/learn

Node.js tutorial Learn in 3 days: https://www.guru99.com/node-js-tutorial.html

--

--