Home·Terminal commands

npm ci

Packages and runtimes

Usage

npm ci [--omit=dev]

Deletes node_modules and installs exactly what package-lock.json says; it never edits the lockfile and fails outright when the lockfile and package.json disagree, which is why CI uses it instead of install.

Common flags

FlagMeaning
--omit=devproduction dependencies only
--ignore-scriptsskip lifecycle scripts, common in CI
--prefer-offlineuse the cache whenever it can
--no-auditskip the vulnerability check for speed
--cache <dir>point at a cache directory the CI runner keeps

Examples

npm ci

deletes node_modules and installs exactly what the lockfile says

npm ci --omit=dev

a production install for a container image

npm ci --ignore-scripts

installs without running third-party install hooks

The question is always what goes where: inside this project, or on the whole machine.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does npm ci do?

Deletes node_modules and installs exactly what package-lock.json says; it never edits the lockfile and fails outright when the lockfile and package.json disagree, which is why CI uses it instead of install.

Q. How do I type it?

npm ci [--omit=dev] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man npm. This command sits under Packages and runtimes.

Related commands

man page: man npm-ci