1NPM-CI(1) NPM-CI(1)
2
3
4
6 npm-ci - Install a project with a clean slate
7
9 npm ci
10
12 Make sure you have a package-lock and an up-to-date install:
13
14 $ cd ./my/npm/project
15 $ npm install
16 added 154 packages in 10s
17 $ ls | grep package-lock
18
19 Run npm ci in that project
20
21 $ npm ci
22 added 154 packages in 5s
23
24 Configure Travis to build using npm ci instead of npm install:
25
26 # .travis.yml
27 install:
28 - npm ci
29 # keep the npm cache around to speed up installs
30 cache:
31 directories:
32 - "$HOME/.npm"
33
35 This command is similar to npm help npm-install, except it's meant to
36 be used in automated environments such as test platforms, continuous
37 integration, and deployment -- or any situation where you want to make
38 sure you're doing a clean install of your dependencies. It can be sig‐
39 nificantly faster than a regular npm install by skipping certain
40 user-oriented features. It is also more strict than a regular install,
41 which can help catch errors or inconsistencies caused by the incremen‐
42 tally-installed local environments of most npm users.
43
44 In short, the main differences between using npm install and npm ci
45 are:
46
47 · The project must have an existing package-lock.json or
48 npm-shrinkwrap.json.
49
50 · If dependencies in the package lock do not match those in pack‐
51 age.json, npm ci will exit with an error, instead of updating the
52 package lock.
53
54 · npm ci can only install entire projects at a time: individual depen‐
55 dencies cannot be added with this command.
56
57 · If a node_modules is already present, it will be automatically
58 removed before npm ci begins its install.
59
60 · It will never write to package.json or any of the package-locks:
61 installs are essentially frozen.
62
63
65 · npm help install
66
67 · npm help 5 package-locks
68
69
70
71
72 April 2019 NPM-CI(1)