Skip to content

Commit

Permalink
update ci-installs.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelCurrin committed May 29, 2024
1 parent 52b1ced commit b7d206b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions recipes/ci-cd/github-actions/workflows/node/ci-installs.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# CI installs
> A note on use of `npm ci`
Some flows here use the `npm ci` command - see [NPM CI cheatsheet](https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/javascript/npm/commands/ci.html) to learn about the command.
Some flows in pages here use the `npm ci` command. This can be safer deploy pipelines. See [NPM CI cheatsheet][] to learn about the command.

A reason to **not** use is that it will delete `node_modules` if it exists. So if you use the `actions/cache` action to retrieved **cached** dependencies each time (for faster builds), make sure to use `npm install` rather than `npm ci`. Otherwise the cache is unused..

For more info on cache, see [Cache](/recipes/ci-cd/github-actions/workflows/cache.md) page of this Cookbook.
## Cache concerns

The equivalent for Yarn:
A reason to **not** use is that it will **delete** `node_modules` if it exists.

```sh
$ yarn install --frozen-lockfile
```
So if you use the `actions/cache` action to retrieved **cached** dependencies each time (for faster builds), make sure to use `npm install` rather than `npm ci`. Otherwise the cache is unused. There is then a risk that packages could get upgraded

For more info on cache, see [Cache][] page of this Cookbook.

You can also solve this issue by caching the tarballs in `~/.npm` rather than `node_modules`. This will safe downloading packages and still let `node_modules` get built each time.

[NPM CI cheatsheet]: https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/package-managers/javascript/npm/commands/ci.html
[Cache]: {% link recipes/ci-cd/github-actions/workflows/cache.md %}

0 comments on commit b7d206b

Please sign in to comment.