Skip to content

Commit 14c4fd4

Browse files
author
Vipul
authored
Merge pull request #690 from pimterry/patch-1
Simplify the Node.js NPM caching example
2 parents 455d267 + ccaf2d8 commit 14c4fd4

1 file changed

Lines changed: 1 addition & 32 deletions

File tree

examples.md

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
- [Java - Gradle](#java---gradle)
1919
- [Java - Maven](#java---maven)
2020
- [Node - npm](#node---npm)
21-
- [macOS and Ubuntu](#macos-and-ubuntu)
22-
- [Windows](#windows-3)
23-
- [Using multiple systems and `npm config`](#using-multiple-systems-and-npm-config)
2421
- [Node - Lerna](#node---lerna)
2522
- [Node - Yarn](#node---yarn)
2623
- [Node - Yarn 2](#node---yarn-2)
@@ -259,40 +256,12 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
259256

260257
## Node - npm
261258

262-
For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows. See https://docs.npmjs.com/cli/cache#cache
259+
For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows, but it's possible to use `npm config get cache` to find the path on any platform. See [the npm docs](https://docs.npmjs.com/cli/cache#cache) for more details.
263260

264261
If using `npm config` to retrieve the cache directory, ensure you run [actions/setup-node](https://github.com/actions/setup-node) first to ensure your `npm` version is correct.
265262

266263
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
267264

268-
### macOS and Ubuntu
269-
270-
```yaml
271-
- uses: actions/cache@v3
272-
with:
273-
path: ~/.npm
274-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
275-
restore-keys: |
276-
${{ runner.os }}-node-
277-
```
278-
279-
### Windows
280-
281-
```yaml
282-
- name: Get npm cache directory
283-
id: npm-cache
284-
run: |
285-
echo "::set-output name=dir::$(npm config get cache)"
286-
- uses: actions/cache@v3
287-
with:
288-
path: ${{ steps.npm-cache.outputs.dir }}
289-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
290-
restore-keys: |
291-
${{ runner.os }}-node-
292-
```
293-
294-
### Using multiple systems and `npm config`
295-
296265
```yaml
297266
- name: Get npm cache directory
298267
id: npm-cache-dir

0 commit comments

Comments
 (0)