L1. INTRODUCTION(Node.js & NPM Basics)
What is Node.js?
JavaScript runtime to run JS outside the browser.
Ideal for building server-side applications (APIs, etc.).
Uses NPM (Node Package Manager) for managing packages.
Problem & Solution
Problem:
Manually typing and running each line of code is inefficient.
Solution:
Packages: Pre-written code to simplify tasks.
Download from npmjs.com using NPM commands.
NPM Basics
Installing a Package Globally
npm i -g nodemon
-gflag installs nodemon globally.Avoids restarting server manually.
Running Nodemon
nodemon --version
nodemon index.js
- Runs
index.jswithout needing manual restarts.
Setting Up a Node.js Project
Initializing a Project
npm init
Creates a
package.jsonfile (contains project metadata).Requires inputs like:
Package name
Version
Entry point (default:
index.js)