> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# 清理包管理缓存

::: tip 提示
使用**yarn**、**npm**、**cnpm**、**nvm**等包管理工具安装插件包的时候，会在本地缓存一些插件包。若在安装包管理工具的时候，使用的是默认的安装路径， 则在安装的路径下会产生一个**cache**文件目录（缓存已下载的依赖包），随着时间的推移，开发项目安装的依赖越来越多，慢慢**cache**缓存文件越来越多，系统盘占用也越来越多，为此，想清除**cache**中的依赖文件。方法如下：
:::

## 查看已缓存包的列表

```bash title="查看已缓存包的列表"
yarn cache list
```

## 查询 cache 缓存文件目录路径

```bash title="缓存文件目录路径"
yarn cache dir
```

## 清理缓存包

- **yarn 清除缓存**

```bash title="清除 yarn 缓存"
yarn cache clean
```

- **npm 清除缓存**

```bash title="清除 npm 缓存"
npm cache clean --force
```

## 改变 yarn 的缓存路径

```bash title="改变 yarn 的缓存路径"
yarn config set cache-folder <path>

// 通过指定 --cache-folder 的参数来指定缓存目录
yarn <command> --cache-folder <path>
```
