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 packages in different dependency buckets.

Install a package

Install a runtime dependency.

bashANYnpminstalldeps
bash
npm install <package>
Notes

Install a runtime dependency.

Install a specific version

Install an exact version.

bashANYnpminstallversion
bash
npm install <package>@<version>
Notes

Install an exact version.

Install a dev dependency

Add a development dependency.

bashANYnpminstalldevdependency
bash
npm install -D <package>
Notes

Add a development dependency.

Install an optional dependency

Add an optional dependency.

bashANYnpminstalloptional
bash
npm install -O <package>
Notes

Add an optional dependency.

Install as peer dependency

Add a peer dependency entry.

bashANYnpminstallpeer
bash
npm install -P <package>
Notes

Add a peer dependency entry.

Install without saving

Install a package without editing package.json.

bashANYnpminstallno-save
bash
npm install --no-save <package>
Notes

Install a package without editing package.json.

Install globally

Install a CLI tool globally.

bashANYnpminstallglobal
bash
npm install -g <package>
Notes

Install a CLI tool globally.

Update and remove dependencies

Change package versions and clean up dependencies.

Remove a package

Remove a dependency and update manifests.

bashANYnpmuninstall
bash
npm uninstall <package>
Notes

Remove a dependency and update manifests.

Update matching packages

Update installed packages within semver ranges.

bashANYnpmupdate
bash
npm update
Notes

Update installed packages within semver ranges.

Update one package

Update one installed package.

bashANYnpmupdate
bash
npm update <package>
Notes

Update one installed package.

Deduplicate dependencies

Reduce duplicate package copies in the tree.

bashANYnpmdedupe
bash
npm dedupe
Notes

Reduce duplicate package copies in the tree.

Remove extraneous packages

Delete packages not listed in manifests.

bashANYnpmprune
bash
npm prune
Notes

Delete packages not listed in manifests.

Find duplicate packages

Report duplicate package copies in the tree.

bashANYnpmduplicates
bash
npm find-dupes
Notes

Report duplicate package copies in the tree.

Lockfiles and reproducible installs

Commands that matter for CI and predictable installs.

CI install without lifecycle scripts

Perform a clean install while skipping lifecycle scripts.

bashANYnpmcisecurity
bash
npm ci --ignore-scripts
Notes

Perform a clean install while skipping lifecycle scripts.

Refresh lockfile only

Update package-lock.json without changing node_modules.

bashANYnpmlockfile
bash
npm install --package-lock-only
Notes

Update package-lock.json without changing node_modules.

Create npm-shrinkwrap.json

Create a publishable lockfile.

bashANYnpmshrinkwraplockfile
bash
npm shrinkwrap
Notes

Create a publishable lockfile.

Install with legacy peer handling

Bypass peer dependency auto-resolution conflicts.

bashANYnpminstallpeer-deps
bash
npm install --legacy-peer-deps
Notes

Bypass peer dependency auto-resolution conflicts.

Install production deps only

Skip devDependencies during install.

bashANYnpminstallproduction
bash
npm install --omit=dev
Notes

Skip devDependencies during install.

CI install production deps only

Use lockfile while skipping devDependencies.

bashANYnpmciproduction
bash
npm ci --omit=dev
Notes

Use lockfile while skipping devDependencies.

Local development and linking

Useful local package development commands.

Pack the current package

Create a tarball from the current package.

bashANYnpmpack
bash
npm pack
Notes

Create a tarball from the current package.

Install from local tarball

Install a package from a local tarball.

bashANYnpminstalltarball
bash
npm install ./my-package-1.0.0.tgz
Notes

Install a package from a local tarball.

Recommended next

No recommendations yet.