NPM-CI(1)

πŸ’… npm-ci(1) β€” the clean-install glow-up

okay bestie, welcome to npm-ci(1), aka npm-ci β€” Clean install a project. this is the page for the moment your CI pipeline needs to be ✨immaculate✨ and you simply cannot be out here trusting npm install to behave. let's get into it πŸŽ€


✨ NAME ✨

npm-ci β€” Clean install a project. that's the whole vibe. it cleans, it installs, it does not negotiate. πŸ’…


🌸 Synopsis 🌸

npm ci

aliases: clean-install, ic, install-clean, isntall-clean

yes bestie, isntall-clean is a real alias. that's not a typo, that's canon. iykyk 😭


πŸ¦‹ Description πŸ¦‹

okay so this command is basically npm help install's responsible older sister. it's built for automated environments β€” test platforms, continuous integration, deployment β€” or literally any sitch where you need to make absolutely sure you're doing a clean install of your dependencies. no vibes, no drift, just a fresh lockfile-accurate install. ✨

the main differences between using npm install and npm ci are, and i quote the entire list because every single one matters:

  • The project must have an existing package-lock.json. no lockfile, no install, periodt.
  • If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock. it refuses to rewrite reality for you πŸ™ˆ
  • npm ci can only install entire projects at a time: individual dependencies cannot be added with this command. it's all-or-nothing energy.
  • If a node_modules is already present, it will be automatically removed before npm ci begins its install. yes, nuked. gone. slay.
  • It will never write to package.json or package-lock.json: installs are essentially frozen. 🧊
NOTE: if you create your package-lock.json file by running npm install with flags that can affect the shape of your dependency tree β€” things like --legacy-peer-deps or --install-links β€” you must provide the same flags to npm ci or you are likely to encounter errors. an easy way to do this is to run, for example, npm config set legacy-peer-deps=true --location=project and commit the .npmrc file to your repo. config drift is the villain of this story, don't let it win πŸ’€

πŸŽ€ Example πŸŽ€

first up: make sure you have a package-lock and an up-to-date install. like, actually do this, bestie:

$ cd ./my/npm/project
$ npm install
added 154 packages in 10s
$ ls | grep package-lock

then run npm ci in that project:

$ npm ci
added 154 packages in 5s

see that? 5s versus 10s. the lockfile said let me cook πŸ”₯

and if you wanna configure Travis CI to build using npm ci instead of npm install, here's the exact snippet:

# .travis.yml
install:
- npm ci
# keep the npm cache around to speed up installs
cache:
  directories:
  - "$HOME/.npm"

the cache comment stays, because caching is self-care 🧚


πŸ‘‘ Configuration πŸ‘‘

this is the big one. every setting, every default, every deprecation warning β€” nothing gets skipped. buckle up, we're going through all of them. 🌈

🌟 install-strategy 🌟

  • Default: "hoisted"
  • Type: "hoisted", "nested", "shallow", or "linked"

sets the strategy for installing packages in node_modules. here's the breakdown, no cap:

  • hoisted (default): install non-duplicated in top-level, and duplicated as necessary within directory structure.
  • nested: (formerly --legacy-bundling) install in place, no hoisting.
  • shallow: (formerly --global-style) only install direct deps at top-level.
  • linked: install in node_modules/.store, link in place, unhoisted.

and here's the rec, straight from the page: we recommend that package authors use --install-strategy=linked during development to catch undeclared ("phantom") dependencies before publishing. the isolated layout only exposes a package's declared dependencies, so an import of a package that was never added to package.json can fail instead of resolving by accident and shipping broken. see Catching undeclared ("phantom") dependencies ⟨/using-npm/developers#catching-undeclared-phantom-dependencies⟩. catching your own lies before publish = main character energy πŸ‘‘

πŸ’œ legacy-bundling πŸ’œ

  • Default: false
  • Type: Boolean
  • DEPRECATED: This option has been deprecated in favor of --install-strategy=nested

instead of hoisting package installs in node_modules, install packages in the same manner that they are depended on. this may cause very deep directory structures and duplicate package installs as there is no de-duplicating. sets --install-strategy=nested. it's deprecated for a reason babe, tread carefully 😭

πŸ“ global-style πŸ“

  • Default: false
  • Type: Boolean
  • DEPRECATED: This option has been deprecated in favor of --install-strategy=shallow

only install direct dependencies in the top level node_modules, but hoist on deeper dependencies. sets --install-strategy=shallow. again: deprecated, so like, use the new thing ✨

🌸 omit 🌸

  • Default: 'dev' if the NODE_ENV environment variable is set to 'production'; otherwise, empty.
  • Type: "dev", "optional", or "peer" (can be set multiple times)

dependency types to omit from the installation tree on disk. but listen β€” note that these dependencies are still resolved and added to the package-lock.json file. they are just not physically installed on disk. so they're on the guest list but not in the building πŸ’…

if a package type appears in both the --include and --omit lists, then it will be included. inclusion wins, always, no matter the order.

and if the resulting omit list includes 'dev', then the NODE_ENV environment variable will be set to 'production' for all lifecycle scripts. that's a big deal, don't sleep on it πŸ”₯

🧚 include 🧚

  • Default: (empty)
  • Type: "prod", "dev", "optional", or "peer" (can be set multiple times)

the option that lets you define which types of dependencies to install. this is the literal inverse of --omit=<type>. πŸ™ƒ

dependency types specified in --include will not be omitted, regardless of the order in which omit/include are specified on the command-line. order doesn't matter, include just wins. iconic.

πŸ¦‹ strict-peer-deps πŸ¦‹

  • Default: false
  • Type: Boolean

if set to true, and --legacy-peer-deps is not set, then any conflicting peerDependencies will be treated as an install failure β€” even if npm could reasonably guess the appropriate resolution based on non-peer dependency relationships. no guessing games allowed πŸ”₯

by default, conflicting peerDependencies deep in the dependency graph will be resolved using the nearest non-peer dependency specification, even if doing so will result in some packages receiving a peer dependency outside the range set in their package's peerDependencies object. so like, it's doing its best 😭

when such an override is performed, a warning is printed, explaining the conflict and the packages involved. but if --strict-peer-deps is set, then this warning is treated as a failure. warning β†’ error, glow-up β†’ glow-down πŸ’€

πŸŽ€ foreground-scripts πŸŽ€

  • Default: false unless when using npm pack or npm publish where it defaults to true
  • Type: Boolean

run all build scripts (ie, preinstall, install, and postinstall) scripts for installed packages in the foreground process, sharing standard input, output, and error with the main npm process. so you see everything live, in real time, no filter 🫢

note that this will generally make installs run slower, and be much noisier, but can be useful for debugging. loud and slow but honest, honestly a mood.

πŸ’– ignore-scripts πŸ’–

  • Default: false
  • Type: Boolean

if true, npm does not run scripts specified in package.json files.

note that commands explicitly intended to run a particular script β€” such as npm start, npm stop, npm restart, npm test, and npm run β€” will still run their intended script if ignore-scripts is set, but they will not run any pre- or post-scripts. the main script shows up, the entourage stays home πŸ’…

setting ignore-scripts also disables .npm-extension execution, as if ignore-extension were set. sneaky little side effect, but it's right there in the docs.

🌈 allow-directory 🌈

  • Default: "all"
  • Type: "all", "none", or "root"

limits the ability for npm to install dependencies from directories. that is, dependencies that point to a directory instead of a version or semver range. please note that this could leave your tree incomplete and some packages may not function as intended or designed. changing this setting will not remove dependencies that are already installed. πŸ™ˆ

  • all allows any directories to be installed.
  • none prevents any directories from being installed.
  • root only allows directories defined in your project's package.json to be installed. also allows directory dependencies to be used for other commands like npm view.

⭐ allow-file ⭐

  • Default: "all"
  • Type: "all", "none", or "root"

limits the ability for npm to install dependencies from tarball files. that is, dependencies that point to a local tarball file instead of a version or semver range. same warning as above: this could leave your tree incomplete and some packages may not function as intended or designed, and changing this setting will not remove dependencies that are already installed. 🫠

  • all allows any tarball file to be installed.
  • none prevents any tarball file from being installed.
  • root only allows tarball files defined in your project's package.json to be installed. also allows tarball file dependencies to be used for other commands like npm view.

πŸ’œ allow-git πŸ’œ

  • Default: "none"
  • Type: "all", "none", or "root"

limits the ability for npm to fetch dependencies from git references. that is, dependencies that point to a git repo instead of a version or semver range. yep, same note: this could leave your tree incomplete and some packages may not function as intended or designed, and changing this setting will not remove dependencies that are already installed. πŸ’€

as of npm 12 the default is none. git dependencies run git against a remote repo and may install configuration the project does not control. opt in explicitly per project (in .npmrc) or per command (on the CLI) when you need git deps. that's not a suggestion bestie, that's a security posture πŸ‘‘

  • all allows any git dependencies to be fetched and installed.
  • none prevents any git dependencies from being fetched and installed.
  • root only allows git dependencies defined in your project's package.json to be fetched and installed. also allows git dependencies to be fetched for other commands like npm view.

🌸 allow-remote 🌸

  • Default: "none"
  • Type: "all", "none", or "root"

limits the ability for npm to fetch dependencies from urls. that is, dependencies that point to a tarball url instead of a version or semver range. and yes, once more: this could leave your tree incomplete and some packages may not function as intended or designed, and changing this setting will not remove dependencies that are already installed. 😭

as of npm 12 the default is none. tarballs that share a hostname with the configured registry (the typical case for the npm registry, GitHub Packages, and most private registries) are still installed normally. if your registry serves tarballs from a different host, set replace-registry-host or override this setting. opt in explicitly per project (in .npmrc) or per command (on the CLI) when you intentionally install from a URL. iykyk, the hostname detail is the whole plot twist πŸŽ€

  • all allows any url to be installed.
  • none prevents any url from being installed.
  • root only allows urls defined in your project's package.json to be installed. also allows url dependencies to be used for other commands like npm view.

πŸ¦‹ allow-scripts πŸ¦‹

  • Default: ""
  • Type: String (can be set multiple times)

comma-separated list of packages whose install-time lifecycle scripts (preinstall, install, postinstall, and prepare for non-registry dependencies) are allowed to run. so like, a tiny VIP list for scripts πŸ”₯

this setting is intended for one-off and global contexts: npm exec, npx, and npm install -g, where no project package.json is involved. for team-wide policy in a project, use the allowScripts field in package.json (which also supports explicit denials), or configure it in .npmrc. and heads up β€” passing --allow-scripts on the command line during a project-scoped npm install, ci, update, or rebuild is an error. not a warning, an error. πŸ’€

each name is matched against a dependency's resolved identity, not against the package's self-reported name. --ignore-scripts and --dangerously-allow-all-scripts both override this setting. also, this value is not exported to the environment for child processes. 🫢

πŸ“ strict-allow-scripts πŸ“

  • Default: false
  • Type: Boolean β€” literally just true-or-false energy πŸ’…

If it's true, the install-script policy goes from a lil warning to a hard error: any dependency with install scripts that is not covered by allowScripts will fail the install instead of getting blocked with a warning. So like, no more soft-launch, bestie β€” it's a full-on hard launch or nothing 🫢

Dependencies explicitly denied with false in allowScripts are always silently skipped (no drama, no message, they just get ghosted πŸ™ˆ). This setting only affects unreviewed entries β€” i.e. packages with install scripts that are neither approved nor denied. And heads up: --ignore-scripts and --dangerously-allow-all-scripts both override this setting, so those two flags are the main characters here πŸ‘‘

Optional dependencies that can't be installed on the current platform or engine (a non-matching os, cpu, or libc) are not flagged, because their install scripts literally never run in the first place. Nothing to warn about, nothing to see πŸ’€


  • dangerously-allow-all-scripts β€” Default: false, Type: Boolean

If true, it bypasses the allowScripts policy entirely and runs every dependency install script regardless of whether it was approved or denied 😭 Intended as a migration escape hatch only β€” its use is strongly discouraged, like genuinely, please don't. --ignore-scripts still takes precedence over this setting, so that one wins the argument every time πŸ’…

  • audit β€” Default: true, Type: Boolean

When it's "true", npm submits audit reports alongside the current npm command to the default registry and to all registries configured for scopes. Wanna know what exactly gets submitted? Peep the docs in npm help audit, it's all laid out there πŸ”

  • bin-links β€” Default: true, Type: Boolean

Tells npm to create symlinks (or .cmd shims on Windows) for package executables ✨ Set it to false and npm simply won't. Iconic workaround behaviour: this exists because some file systems just do not support symlinks β€” even on ostensibly Unix systems. Rude, but real πŸ₯²

  • fund β€” Default: true, Type: Boolean

When "true", it displays the message at the end of each npm install acknowledging the number of dependencies looking for funding πŸ’Έ See npm help fund for the full story.

  • dry-run β€” Default: false, Type: Boolean

Tells npm: don't actually do anything, just tell me what you would've done πŸ¦‹ You can pass this into any of the commands that modify your local installation, eg install, update, dedupe, uninstall, as well as pack and publish.

Note: this is NOT honored by other network related commands, eg dist-tags, owner, etc. So don't come crying to me when those still go off 😌
  • workspace β€” Default: (empty), Type: String (can be set multiple times)

Enable running a command in the context of the configured workspaces of the current project, while filtering by running only the workspaces defined by this config option πŸŽ€

Valid values for the workspace config are either:

  • Workspace names
  • Path to a workspace directory
  • Path to a parent workspace directory (this one will result in selecting all workspaces within that folder)

When set for the npm init command, this may be set to the folder of a workspace which does not yet exist β€” so npm creates the folder and sets it up as a brand new workspace within the project 🌱

This value is not exported to the environment for child processes.

  • workspaces β€” Default: null, Type: null or Boolean

Set to true to run the command in the context of all configured workspaces πŸ‘‘

Explicitly setting this to false will cause commands like install to ignore workspaces altogether. When it's not set explicitly:

  • Commands that operate on the node_modules tree (install, update, etc.) will link workspaces into the node_modules folder.
  • Commands that do other things (test, exec, publish, etc.) will operate on the root project, unless one or more workspaces are specified in the workspace config.

This value is not exported to the environment for child processes.

  • include-workspace-root β€” Default: false, Type: Boolean

Include the workspace root when workspaces are enabled for a command 🫢

When false, specifying individual workspaces via the workspace config β€” or all workspaces via the workspaces flag β€” will cause npm to operate only on the specified workspaces, and not on the root project. Root stays in its lane.

This value is not exported to the environment for child processes.

  • install-links β€” Default: false, Type: Boolean

When set, file: protocol dependencies will be packed and installed as regular dependencies instead of creating a symlink πŸ”— This option has no effect on workspaces, so don't even try it there.


🌈 See Also 🌈

  • npm help install
  • package-lock.json ⟨/configuring-npm/package-lock-json⟩

okay that's the whole page bestie, you made it to the end, I'm so proud of you πŸ˜­πŸ’– this was NPM-CI(1) from source/version NPM@12.2.1, dated October 2026 β€” go forth and install responsibly, no cap βœ¨πŸŽ€πŸ‘‘

πŸ“¦ where this page comes from