Understanding Node.js: Pros, Use Cases, and How to Set It Up on Windows.

Rahul Kumar
3 min readSep 9, 2024

--

What is Node.js?

→ Nodejs is a Javascript runtime that runs on V8 (V8 is an open-source engine developed by the google chrome browser).

→ Traditionaly JavaScript engines are available in browsers only but Node allows us to run and write code outside the browsers.

→ By using Node, You can start using JavaScript on server side itself. that means If you know only JavaScript you can write both front-end and backend. that makes Full stack development.

Pros of Nodejs:

  • Perfect for building fast and scalable data intensive apps.
  • Javascript across the entire stack(Client and server side both), faster and more efficient development.
  • Node.js is single-threaded so it can only do ne process at one time.
  • Node.js is asynchronous and non-blocking. This means, while a process is being executed, the program doesn’t have to wait until the process fininshes.
  • Node.js is event-driven. When Node.js performs an input/output (I/O) operation, like reading from the network, accessing a database or the file system, an event is triggered. Instead of blocking the thread and wasting the processor time waiting, Node.js will resume the operations when the response comes back or, in other words, the response event occurs. During that time, the server is not blocked and can do other things, which makes it look like it is multi-threaded.

Use Case of Nodejs:

  • API with database behind it.
  • Data streaming
  • Real time chat application
  • Server-side web applications.
  • Node.js is used by companies like Uber, Yahoo!, LinkedIn, GoDaddy, Ebay and PayPal.

Note:

  • Don’t use In case of Applications with heavy server-side processing(CPU intensive).
  • Processes: Processes in a server can be “single-threaded” or “multi-threaded.
  • Single-threaded is where only one command is processed at a given point in time.
  • Multi-threaded is where multiple commands are processed simultaneously.

How to Setup Nodejs on windows ?

Step 1. Got to Official Nodejs website by using given link

https://nodejs.org/en

and download Nodejs LTS version.

Step 2. Install it by clicking next.

Step 3. Open command prompt and write this command to check nodejs version

How to use Node in command line?

  1. To run javascript outside browser, you need to run node command and you can write javascript code to run:

example:

You can see in above image, It is also called REPL(Read Evaluate Print Loop). In REPL, we can run any javascript code.

_ (underscore) means previous value in command line.

example:

2. If you want to See global variables and modules of Nodejs then here is a way to see that:

Go to command line and run node command and press tab once or twice it will show you the global modules and variables.

3. If you forgot some methods of some Object like String, you can see here too.

→ Just write that object name with . then press tab, It will give all the methods of that Object.

Thanks…

--

--