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

Payal PorwalPayal Porwal
3 min read

๐Ÿ‘ฉโ€๐Ÿ’ป 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

  1. Visit: https://nodejs.org

  2. Download the LTS version (Long-Term Support)

  3. 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

ConceptDescription
Node.jsJS runtime to run code outside the browser
Terminal/Command LineUsed to run .js files directly using node command
console.log()Prints output in the terminal
.js fileNormal JavaScript file used for scripting in Node.js
Real-life use caseCan be used in form handling, APIs, automation, etc.

๐Ÿ“ Practice Tasks for Students

  1. Create a file multiply.js to multiply two numbers

  2. Write a file bio.js that prints your name, age, and city

  3. Run 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!

0
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! ๐ŸŒŸ