Package Managers
programmingpackage-managersGuideBeginner
Installing Packages (`npm install` / `pnpm add`)
Complete guide to installing packages, installing specific versions, Git repositories, local tarballs, global packages, and dependency flags.
Verified: 2026-09-30
Tested on:npm 10.x, pnpm 9.x
Platforms:
linuxmacoswindows
#install#npm#pnpm#packages
The install (or add) command downloads and links third-party packages into your project workspace.
Installing All Project Dependencies
When cloning an existing repository, install all dependencies listed in package.json:
# npm
npm install
# pnpm
pnpm install
# In CI/CD pipelines (Strict lockfile enforcement)
npm ci
pnpm install --frozen-lockfileAdding New Packages
1. Runtime Dependencies
# npm
npm install zod axios
# pnpm
pnpm add zod axios2. Development Dependencies
# npm
npm install -D typescript vitest
# pnpm
pnpm add -D typescript vitest3. Installing Specific Versions or Tags
# Exact version
npm install react@18.2.0
# Latest beta or next tag
npm install next@canary4. Installing from GitHub / Git URLs
# Install directly from main branch of GitHub repo
npm install github:user/repo
# Install from specific Git commit SHA or tag
npm install git+https://github.com/user/repo.git#v2.1.05. Installing Local Packages or Tarballs
# Relative local directory
npm install ../my-local-package
# Packaged tarball (.tgz)
npm install ./dist/my-package-1.0.0.tgzRelated Guides
Understanding node_modules & Resolution
Complete guide to the node_modules folder, Node.js module resolution algorithm, flat vs nested trees, phantom dependencies, and cleaning corrupted caches.
Removing Packages (`npm uninstall` / `pnpm remove`)
Guide to uninstalling dependencies from package.json and node_modules, cleaning orphaned transitive packages, and removing global packages.