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