Labs ICT
Pro Login

What is npm? A Beginner's Guide to Node Packages

JavaScript Tools & Setup 6 min read

npm gives you access to millions of code packages. Learn what npm is, how to use it, and popular packages.

What is npm? A Beginner's Guide to Node Packages

npm (Node Package Manager) is the world's largest software registry. It gives you access to millions of code packages that solve common problems.

What is npm?

npm is a tool that comes with Node.js. It lets you install, share, and manage code packages. Instead of writing everything from scratch, you can use packages that others have created.

Basic npm Commands

# Initialize a new project
npm init -y

# Install a package
npm install express

# Install a package globally
npm install -g nodemon

# Install a development dependency
npm install --save-dev jest

# Remove a package
npm uninstall express

# See outdated packages
npm outdated

package.json

Every Node.js project has a package.json file. It lists your project's dependencies and scripts:

{
  "name": "my-app",
  "version": "1.0.0",
  "dependencies": {
    "express": "^4.18.0"
  },
  "devDependencies": {
    "jest": "^29.0.0"
  },
  "scripts": {
    "start": "node app.js",
    "test": "jest"
  }
}

Popular npm Packages

Package Purpose
express Web framework
lodash Utility functions
axios HTTP requests
dotenv Environment variables
nodemon Auto-restart server

npm Scripts

Custom scripts automate tasks:

{
  "scripts": {
    "start": "node app.js",
    "dev": "nodemon app.js",
    "test": "jest",
    "build": "webpack --mode production"
  }
}

Run with npm run dev, npm test, etc.

Note: npm is essential for Node.js development. Learn the basics early — you'll use it in every project.