๐ Day 1: Introduction to Node.js โ Setup, Running JavaScript in Terminal

Table of contents
- ๐ฉโ๐ป Target Audience:
- ๐ What is Node.js?
- ๐ง Why Node.js?
- ๐ ๏ธ How to Setup Node.js on Your Computer
- โ๏ธ Writing Your First Node.js Program
- ๐ฏ Real-Life Example: Create a Calculator (Addition Only)
- ๐งฉ Key Concepts You Learned Today
- ๐ Practice Tasks for Students
- ๐จโ๐ป For Working Professionals
- โ Summary
๐ฉโ๐ป Target Audience:
Freshers & Students learning backend
Working professionals revising Node.js basics
Anyone transitioning from frontend to full-stack
๐ What is Node.js?
Node.js is a JavaScript runtime that allows you to run JavaScript outside the browser, especially on a server.
๐ Normally, we use JavaScript in the browser (like in React or plain JS).
But with Node.js, we can use JavaScript to build:
Web servers
APIs
CLI tools
Backend logic (databases, file handling, etc.)
๐ง Why Node.js?
Hereโs why developers love Node.js:
โ
You can use the same language (JavaScript) on frontend and backend
โ
Itโs fast and event-driven, suitable for real-time apps (like chats)
โ
It has a huge ecosystem (via npm) for ready-to-use libraries
โ
Used by big companies like Netflix, PayPal, LinkedIn
๐ ๏ธ How to Setup Node.js on Your Computer
Step 1: Download Node.js
Visit: https://nodejs.org
Download the LTS version (Long-Term Support)
Install it like normal software (next-next-finish)
๐ก Node.js comes with npm (Node Package Manager) by default.
Step 2: Check Installation
Open your terminal or command prompt and type:
node -v
This will show Node.js version like:
v20.10.0
Now check npm:
npm -v
Youโll see something like:
10.5.0
โ๏ธ Writing Your First Node.js Program
Letโs create a simple program that prints your name.
Step 1: Create a File
Make a file called intro.js
and write:
console.log("Hello from Node.js! My name is Payal.");
Step 2: Run the Program in Terminal
In terminal, go to the folder where intro.js
is saved:
cd path-to-your-folder
Now run the file using:
node intro.js
โ Youโll see this output:
Hello from Node.js! My name is Payal.
๐ Congratulations! You just ran your first Node.js program.
๐ฏ Real-Life Example: Create a Calculator (Addition Only)
Let's say you want to create a backend tool that calculates the sum of two numbers.
Create a file called add.js
:
const num1 = 10;
const num2 = 20;
const sum = num1 + num2;
console.log("The sum is:", sum);
Run:
node add.js
Output:
The sum is: 30
๐ In real life, backend logic like this can come from a form input (e.g. on a shopping website).
๐งฉ Key Concepts You Learned Today
Concept | Description |
Node.js | JS runtime to run code outside the browser |
Terminal/Command Line | Used to run .js files directly using node command |
console.log() | Prints output in the terminal |
.js file | Normal JavaScript file used for scripting in Node.js |
Real-life use case | Can be used in form handling, APIs, automation, etc. |
๐ Practice Tasks for Students
Create a file
multiply.js
to multiply two numbersWrite a file
bio.js
that prints your name, age, and cityRun both programs using
node filename.js
in terminal
๐จโ๐ป For Working Professionals
Node.js enables you to:
Automate tasks (e.g., file processing, scheduling)
Build backend services quickly
Work with APIs and databases using a unified language (JS)
Integrate with frontend (React/Angular) smoothly in full-stack apps
โ Summary
๐น Node.js lets you run JavaScript on your system, not just browser
๐น It is lightweight, fast, and perfect for backend development
๐น You wrote and ran your first backend program
๐น Now youโre ready to build on this with file systems, servers, and databases!
Subscribe to my newsletter
Read articles from Payal Porwal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Payal Porwal
Payal Porwal
Hi there, tech enthusiasts! I'm a passionate Software Developer driven by a love for continuous learning and innovation. I thrive on exploring new tools and technologies, pushing boundaries, and finding creative solutions to complex problems. What You'll Find Here On my Hashnode blog, I share: ๐ In-depth explorations of emerging technologies ๐ก Practical tutorials and how-to guides ๐งInsights on software development best practices ๐Reviews of the latest tools and frameworks ๐ก Personal experiences from real-world projects. Join me as we bridge imagination and implementation in the tech world. Whether you're a seasoned pro or just starting out, there's always something new to discover! Letโs connect and grow together! ๐