---
url: https://eoht.net/fe/pnpm/mirror.md
description: 学习如何使用 pnpm 切换国内镜像源，提升 Node.js 包管理速度，并恢复到默认源。
---

# pnpm 切换镜像及恢复默认源 使用国内镜像加速安装 {#pnpm-registry-mirror-guide}

## 验证当前NPM源地址 {#check-current-npm-registry}

```sh
pnpm config get registry
```

## 国内镜像 {#configure-chinese-npm-registry-mirrors}

::: code-group

```sh [腾讯云]
pnpm config set registry http://mirrors.cloud.tencent.com/npm/
```

```sh [淘宝]
pnpm config set registry https://registry.npmmirror.com
```

```sh [华为云]
pnpm config set registry https://mirrors.huaweicloud.com/repository/npm/
```

:::

## 恢复默认源 {#restore-default-npm-registry}

```sh
pnpm config set registry=https://registry.npmjs.org
```

## 通过使用淘宝定制的cnpm安装 {#install-with-taobao-cnpm}

```sh
pnpm install -g cnpm --registry=https://registry.npmmirror.com   # 安装cnpm
cnpm install xxx    # 使用cnpm
```
