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
| Flag | Meaning |
|---|---|
| --omit=dev | production dependencies only |
| --ignore-scripts | skip lifecycle scripts, common in CI |
| --prefer-offline | use the cache whenever it can |
| --no-audit | skip the vulnerability check for speed |
| --cache <dir> | point at a cache directory the CI runner keeps |
Examples
npm cideletes node_modules and installs exactly what the lockfile says
npm ci --omit=deva production install for a container image
npm ci --ignore-scriptsinstalls 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