1 ---
2 title: npm-ci
3 section: 1
4 description: Clean install a project
5 github_repo: npm/cli
6 github_branch: latest
7 github_path: docs/lib/content/commands/npm-ci.md
8 redirect_from:
9 - /cli-commands/ci
10 - /cli-commands/npm-ci
11 - /cli-documentation/ci
12 - /cli-documentation/cli-commands/ci
13 - /cli-documentation/cli-commands/npm-ci
14 - /cli-documentation/commands/ci
15 - /cli-documentation/commands/npm-ci
16 - /cli-documentation/npm-ci
17 - /cli-documentation/v11/ci
18 - /cli-documentation/v11/cli-commands/ci
19 - /cli-documentation/v11/cli-commands/npm-ci
20 - /cli-documentation/v11/commands/ci
21 - /cli-documentation/v11/commands/npm-ci
22 - /cli-documentation/v11/npm-ci
23 - /cli/ci
24 - /cli/cli-commands/ci
25 - /cli/cli-commands/npm-ci
26 - /cli/commands/ci
27 - /cli/commands/npm-ci
28 - /cli/npm-ci
29 - /cli/v11/ci
30 - /cli/v11/cli-commands/ci
31 - /cli/v11/cli-commands/npm-ci
32 - /cli/v11/commands/ci
33 - /cli/v11/npm-ci
34 - /commands/ci
35 - /commands/npm-ci
36 ---
37
38 ### Synopsis
39
40 ```bash
41 npm ci
42
43 aliases: clean-install, ic, install-clean, isntall-clean
44 ```
45
46 ### Description
47
48 This command is similar to [`npm install`](/cli/v11/commands/npm-install), except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies.
49
50 The main differences between using `npm install` and `npm ci` are:
51
52 - The project **must** have an existing `package-lock.json` or `npm-shrinkwrap.json`.
53 - 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.
54 - `npm ci` can only install entire projects at a time: individual dependencies cannot be added with this command.
55 - If a `node_modules` is already present, it will be automatically removed before `npm ci` begins its install.
56 - It will never write to `package.json` or any of the package-locks: installs are essentially frozen.
57
58 NOTE: If you create your `package-lock.json` file by running `npm install` with flags that can affect the shape of your dependency tree, such as `--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.
59
60 ### Example
61
62 Make sure you have a package-lock and an up-to-date install:
63
64 ```bash
65 $ cd ./my/npm/project
66 $ npm install
67 added 154 packages in 10s
68 $ ls | grep package-lock
69 ```
70
71 Run `npm ci` in that project
72
73 ```bash
74 $ npm ci
75 added 154 packages in 5s
76 ```
77
78 Configure Travis CI to build using `npm ci` instead of `npm install`:
79
80 ```bash
81 # .travis.yml
82 install:
83 - npm ci
84 # keep the npm cache around to speed up installs
85 cache:
86 directories:
87 - "$HOME/.npm"
88 ```
89
90 ### Configuration
91
92 #### `install-strategy`
93
94 - Default: "hoisted"
95 - Type: "hoisted", "nested", "shallow", or "linked"
96
97 Sets the strategy for installing packages in node_modules. 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: (experimental) install in node_modules/.store, link in place, unhoisted.
98
99 #### `legacy-bundling`
100
101 - Default: false
102 - Type: Boolean
103 - DEPRECATED: This option has been deprecated in favor of `--install-strategy=nested`
104
105 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`.
106
107 #### `global-style`
108
109 - Default: false
110 - Type: Boolean
111 - DEPRECATED: This option has been deprecated in favor of `--install-strategy=shallow`
112
113 Only install direct dependencies in the top level `node_modules`, but hoist on deeper dependencies. Sets `--install-strategy=shallow`.
114
115 #### `omit`
116
117 - Default: 'dev' if the `NODE_ENV` environment variable is set to 'production'; otherwise, empty.
118 - Type: "dev", "optional", or "peer" (can be set multiple times)
119
120 Dependency types to omit from the installation tree on disk.
121
122 Note that these dependencies _are_ still resolved and added to the `package-lock.json` or `npm-shrinkwrap.json` file. They are just not physically installed on disk.
123
124 If a package type appears in both the `--include` and `--omit` lists, then it will be included.
125
126 If the resulting omit list includes `'dev'`, then the `NODE_ENV` environment variable will be set to `'production'` for all lifecycle scripts.
127
128 #### `include`
129
130 - Default:
131 - Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
132
133 Option that allows for defining which types of dependencies to install.
134
135 This is the inverse of `--omit=<type>`.
136
137 Dependency types specified in `--include` will not be omitted, regardless of the order in which omit/include are specified on the command-line.
138
139 #### `strict-peer-deps`
140
141 - Default: false
142 - Type: Boolean
143
144 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.
145
146 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.
147
148 When such an override is performed, a warning is printed, explaining the conflict and the packages involved. If `--strict-peer-deps` is set, then this warning is treated as a failure.
149
150 #### `foreground-scripts`
151
152 - Default: `false` unless when using `npm pack` or `npm publish` where it defaults to `true`
153 - Type: Boolean
154
155 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.
156
157 Note that this will generally make installs run slower, and be much noisier, but can be useful for debugging.
158
159 #### `ignore-scripts`
160
161 - Default: false
162 - Type: Boolean
163
164 If true, npm does not run scripts specified in package.json files.
165
166 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.
167
168 #### `allow-git`
169
170 - Default: "all"
171 - Type: "all", "none", or "root"
172
173 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. Please note that this could leave your tree incomplete and some packages may not function as intended or designed.
174
175 `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 installed. Also allows git dependencies to be fetched for other commands like `npm view`
176
177 #### `audit`
178
179 - Default: true
180 - Type: Boolean
181
182 When "true" submit audit reports alongside the current npm command to the default registry and all registries configured for scopes. See the documentation for [`npm audit`](/cli/v11/commands/npm-audit) for details on what is submitted.
183
184 #### `bin-links`
185
186 - Default: true
187 - Type: Boolean
188
189 Tells npm to create symlinks (or `.cmd` shims on Windows) for package executables.
190
191 Set to false to have it not do this. This can be used to work around the fact that some file systems don't support symlinks, even on ostensibly Unix systems.
192
193 #### `fund`
194
195 - Default: true
196 - Type: Boolean
197
198 When "true" displays the message at the end of each `npm install` acknowledging the number of dependencies looking for funding. See [`npm fund`](/cli/v11/commands/npm-fund) for details.
199
200 #### `dry-run`
201
202 - Default: false
203 - Type: Boolean
204
205 Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`.
206
207 Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc.
208
209 #### `workspace`
210
211 - Default:
212 - Type: String (can be set multiple times)
213
214 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 configuration option.
215
216 Valid values for the `workspace` config are either:
217
218 - Workspace names
219 - Path to a workspace directory
220 - Path to a parent workspace directory (will result in selecting all workspaces within that folder)
221
222 When set for the `npm init` command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.
223
224 This value is not exported to the environment for child processes.
225
226 #### `workspaces`
227
228 - Default: null
229 - Type: null or Boolean
230
231 Set to true to run the command in the context of **all** configured workspaces.
232
233 Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly:
234
235 - 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.
236
237 This value is not exported to the environment for child processes.
238
239 #### `include-workspace-root`
240
241 - Default: false
242 - Type: Boolean
243
244 Include the workspace root when workspaces are enabled for a command.
245
246 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.
247
248 This value is not exported to the environment for child processes.
249
250 #### `install-links`
251
252 - Default: false
253 - Type: Boolean
254
255 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.
256
257 ### See Also
258
259 - [npm install](/cli/v11/commands/npm-install)
260 - [package-lock.json](/cli/v11/configuring-npm/package-lock-json)