Node.js Fundamentals: Modules, NPM & Packages

🚀 Day 78 Node.js Fundamentals (Modules, NPM & Packages) Today I learned the core building blocks of Node.js, which are essential before starting serious backend development. 🔹 What is Node.js? • Node.js is a JavaScript runtime environment that allows us to run JavaScript outside the browser, mainly on the server. 🔹 Installing Node.js • After installing Node, we can check if it is working with: node -v npm -v 🔹 Node REPL • REPL stands for Read – Evaluate – Print – Loop. It lets us run JavaScript directly in the terminal. 🔹 Running a Node File • We can create a JavaScript file and run it with Node. app.js console.log("Hello from Node.js"); Run the file: node app.js 🔹 Process in Node • Node provides a process object that gives information about the running program. 🔹 Exporting Modules (File Level) We can export functions from one file and use them in another. math.js function add(a, b) {  return a + b; } module.exports = add; app.js const add = require("./math"); console.log(add(2,3)); 🔹 Exporting Modules from a Directory Node automatically reads the index.js file inside a folder. // utils/index.js module.exports = {  name: "Utility Module" }; 🔹 NPM (Node Package Manager) NPM allows us to install and manage libraries for our projects. npm init -y 🔹 package.json This file stores important project information such as: • Project name & version • Installed dependencies • Scripts and configurations Example: {  "name": "node-project",  "version": "1.0.0" } 🔹 Installing Packages • Packages can be installed using NPM: npm install express 🔹 Local vs Global Installation • Local installation (project specific): npm install nodemon • Global installation (available system-wide): npm install -g nodemon 📌 Key Takeaway Today’s learning helped me understand the foundation of Node.js development — REPL, modules, NPM, package management, and running JavaScript on the server. Mastering these basics is the first step toward building scalable backend applications. Continuing my MERN Journey 🚀 #NodeJS #BackendDevelopment #JavaScript #WebDevelopment #LearningInPublic #FullStackJourney

To view or add a comment, sign in

Explore content categories