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 ciwill exit with an error, instead of updating the package lock. it refuses to rewrite reality for you π npm cican only install entire projects at a time: individual dependencies cannot be added with this command. it's all-or-nothing energy.- If a
node_modulesis already present, it will be automatically removed beforenpm cibegins its install. yes, nuked. gone. slay. - It will never write to
package.jsonorpackage-lock.json: installs are essentially frozen. π§
NOTE: if you create yourpackage-lock.jsonfile by runningnpm installwith flags that can affect the shape of your dependency tree β things like--legacy-peer-depsor--install-linksβ you must provide the same flags tonpm cior 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=projectand commit the.npmrcfile 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 innode_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 theNODE_ENVenvironment 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:
falseunless when usingnpm packornpm publishwhere it defaults totrue - 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. π
allallows any directories to be installed.noneprevents any directories from being installed.rootonly allows directories defined in your project'spackage.jsonto be installed. also allows directory dependencies to be used for other commands likenpm 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. π«
allallows any tarball file to be installed.noneprevents any tarball file from being installed.rootonly allows tarball files defined in your project'spackage.jsonto be installed. also allows tarball file dependencies to be used for other commands likenpm 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 π
allallows any git dependencies to be fetched and installed.noneprevents any git dependencies from being fetched and installed.rootonly allows git dependencies defined in your project'spackage.jsonto be fetched and installed. also allows git dependencies to be fetched for other commands likenpm 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 π
allallows any url to be installed.noneprevents any url from being installed.rootonly allows urls defined in your project'spackage.jsonto be installed. also allows url dependencies to be used for other commands likenpm 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, egdist-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:nullor 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_modulestree (install,update, etc.) will link workspaces into thenode_modulesfolder. - Commands that do other things (
test,exec,publish, etc.) will operate on the root project, unless one or more workspaces are specified in theworkspaceconfig.
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 installpackage-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
- arch rolling: npm 12.2.1-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms