npm Install & Dependencies

Install, update, remove, lockfile, and local-development npm dependency workflows.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Installing dependencies
Install a package
npm install <package>

# Install a runtime dependency.

Install a specific version
npm install <package>@<version>

# Install an exact version.

Install a dev dependency
npm install -D <package>

# Add a development dependency.

Install an optional dependency
npm install -O <package>

# Add an optional dependency.

Install as peer dependency
npm install -P <package>

# Add a peer dependency entry.

Install without saving
npm install --no-save <package>

# Install a package without editing package.json.

Install globally
npm install -g <package>

# Install a CLI tool globally.

## Update and remove dependencies
Remove a package
npm uninstall <package>

# Remove a dependency and update manifests.

Update matching packages
npm update

# Update installed packages within semver ranges.

Update one package
npm update <package>

# Update one installed package.

Deduplicate dependencies
npm dedupe

# Reduce duplicate package copies in the tree.

Remove extraneous packages
npm prune

# Delete packages not listed in manifests.

Find duplicate packages
npm find-dupes

# Report duplicate package copies in the tree.

## Lockfiles and reproducible installs
CI install without lifecycle scripts
npm ci --ignore-scripts

# Perform a clean install while skipping lifecycle scripts.

Refresh lockfile only
npm install --package-lock-only

# Update package-lock.json without changing node_modules.

Create npm-shrinkwrap.json
npm shrinkwrap

# Create a publishable lockfile.

Install with legacy peer handling
npm install --legacy-peer-deps

# Bypass peer dependency auto-resolution conflicts.

Install production deps only
npm install --omit=dev

# Skip devDependencies during install.

CI install production deps only
npm ci --omit=dev

# Use lockfile while skipping devDependencies.

## Local development and linking
Pack the current package
npm pack

# Create a tarball from the current package.

Install from local tarball
npm install ./my-package-1.0.0.tgz

# Install a package from a local tarball.

Recommended next

No recommendations yet.