npm-ci.1 2.0 KB

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