Thuta Learning
IntermediateWeb Developmentbeginner

NPM Intro

Relax. We'll talk through this in plain words — no textbook voice.

NPM is the package manager used in Node.js projects to install packages/libraries, manage versions, and run project scripts. When you start a Node.js project, the package.json file acts as the project's ID card.

javascript
# Start a new Node.js project
npm init -y

# Install Express for server development
npm install express

# Install nodemon only for development
npm install --save-dev nodemon

npm init -y creates package.json with the default settings. npm install express adds Express as a dependency needed when the app runs. --save-dev is used for packages that are only needed during development.

You should see
package.json package-lock.json node_modules/

Info

You don't need to upload the node_modules folder to hosting/GitHub. As long as you keep package.json and package-lock.json

Easy traps

  • Before installing a package, make sure you're inside the project folder—otherwise package.json might end up in the wrong place.

Exercise

In real backend projects, NPM is used to manage packages like Express, cors, dotenv, multer, jsonwebtoken, and bcrypt.

You'll know it worked when:

NPM Intro | Thuta Learning