What is Node.js?

Introduction To Node

Welcome to the back-end! The JavaScript language was initially created only for interactive use in the browser. But when the original developers of JavaScript extended it from something you could only run in the browser to something you could run on your machine as a standalone application, Node.js came into existence, which made JavaScript have the capability to do things that other scripting languages like Python can do.

For that; now you can do much more with JavaScript than just making websites interactive.Now with Node.js, we have the capability to run JavaScript on the back-end meaning we can use JavaScript across our entire stack without the need to learn a completely different language.

Learning Objectives:

  • Why Node.js?
  • Explain what Node is.
  • Run applications with Node.
  • Node Debugging tool.


What is Node.js ?

Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool for almost any kind of project!

Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser. This allows Node.js to be very performant.

A Node.js app runs in a single process, without creating a new thread for every request. Node.js provides a set of asynchronous I/O primitives in its standard library that prevent JavaScript code from blocking and generally, libraries in Node.js are written using non-blocking paradigms, making blocking behavior the exception rather than the norm.

When Node.js performs an I/O operation, like reading from the network, accessing a database or the filesystem, instead of blocking the thread and wasting CPU cycles waiting, Node.js will resume the operations when the response comes back. This allows Node.js to handle thousands of concurrent connections with a single server without introducing the burden of managing thread concurrency, which could be a significant source of bugs.

Node.js has a unique advantage because millions of frontend developers that write JavaScript for the browser are now able to write the server-side code in addition to the client-side code without the need to learn a completely different language.

In Node.js the new ECMAScript standards can be used without problems, as you don’t have to wait for all your users to update their browsers – you are in charge of deciding which ECMAScript version to use by changing the Node.js version, and you can also enable specific experimental features by running Node.js with flags.

A Vast Number of Libraries

Many program languages have some sort of package manager associated with them. These package managers help developers when they need to install external libraries and tools for building servers, testing code, and much more. Node’s de facto package manager is NPM .

npm with its simple structure helped the ecosystem of Node.js proliferate, and now the npm registry hosts over 1,000,000 open source packages you can freely use.

Install Node.js:

  • We expect that all of you have installed node.js,if you did you can skip this section, otherwise you can follow the next steps,

  • Go to nodejs.org , download the LTS version and follow the default steps.

  • To check that everything has been correctly set up, open the terminal/console and run the following command:

node --version

If everything is completed successfully, you will be seeing the version of Node.JS displayed on your terminal/console window.

Run applications with Node:

The usual way to run a Node.js program is to run the node globally available command (once you install Node.js) and pass the name of the file you want to execute.

Above, you are explicitly telling the shell to run your script with node.

you can close your running program in the console with ctrl-C.


Additional Resources:

In this section you can find a lot of helpful links to other content. This is a supplemental material for you if you want to dive deeper into some concepts.