# @actions/tool-cache

> Actions tool-cache lib

Latest version **4.0.0** (published 2026-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @actions/tool-cache
pnpm add @actions/tool-cache
yarn add @actions/tool-cache
bun add @actions/tool-cache
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

Negative: declining downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-01-29 |
| First published | 2019-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 106.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 5852 |
| Maintainers | chrispat, bryanmacfarlane, thboop, konradpabjan, bdehamer, joshmgross |
| Keywords | github, actions, exec |

## Links

- npm: https://www.npmjs.com/package/@actions/tool-cache
- Repository: https://github.com/actions/toolkit
- Homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache
- Issues: https://github.com/actions/toolkit/issues
- npm.io page: https://npm.io/package/@actions/tool-cache

## Dependencies (5)

- [semver](https://npm.io/package/semver.md) ^7.7.3
- [@actions/io](https://npm.io/package/@actions/io.md) ^3.0.0
- [@actions/core](https://npm.io/package/@actions/core.md) ^3.0.0
- [@actions/exec](https://npm.io/package/@actions/exec.md) ^3.0.0
- [@actions/http-client](https://npm.io/package/@actions/http-client.md) ^4.0.0

## Recent versions

- 4.0.0 (latest) — 2026-01-29
- 1.5.4 (1.5-preview) — 2020-05-18
- 3.0.1 — 2026-01-27
- 3.0.0 — 2026-01-08
- 2.0.2 — 2025-01-15
- 2.0.1 — 2022-05-13
- 2.0.0 — 2022-05-12
- 1.7.2 — 2022-03-17
- 1.7.1 — 2021-06-07
- 1.7.0 — 2021-05-27
- 1.6.1 — 2020-11-13
- 1.6.0 — 2020-07-16
- 1.5.5 — 2020-05-19
- 1.3.5 — 2020-05-13
- 1.5.3 — 2020-05-02
- … 13 more at https://npm.io/package/@actions/tool-cache/versions

## README

# `@actions/tool-cache`

> Functions necessary for downloading and caching tools.

## Usage

#### Download

You can use this to download tools (or other files) from a download URL:

```js
const tc = require('@actions/tool-cache');

const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
```

#### Extract

These can then be extracted in platform specific ways:

```js
const tc = require('@actions/tool-cache');

if (process.platform === 'win32') {
  const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
  const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');

  // Or alternately
  const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
  const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
}
else if (process.platform === 'darwin') {
  const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0.pkg');
  const node12ExtractedFolder = await tc.extractXar(node12Path, 'path/to/extract/to');
}
else {
  const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
  const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
}
```

#### Cache

Finally, you can cache these directories in our tool-cache. This is useful if you want to switch back and forth between versions of a tool, or save a tool between runs for self-hosted runners.

You'll often want to add it to the path as part of this step:

```js
const tc = require('@actions/tool-cache');
const core = require('@actions/core');

const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');

const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');
core.addPath(cachedPath);
```

You can also cache files for reuse.

```js
const tc = require('@actions/tool-cache');

const cachedPath = await tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
```

#### Find

Finally, you can find directories and files you've previously cached:

```js
const tc = require('@actions/tool-cache');
const core = require('@actions/core');

const nodeDirectory = tc.find('node', '12.x', 'x64');
core.addPath(nodeDirectory);
```

You can even find all cached versions of a tool:

```js
const tc = require('@actions/tool-cache');

const allNodeVersions = tc.findAllVersions('node');
console.log(`Versions of node available: ${allNodeVersions}`);
```

---
_Source: https://npm.io/package/@actions/tool-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
