Files
kazoottt-blog/src/content/post/npm换源.md
2025-01-07 15:27:11 +00:00

70 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: npm换源
date: 2024-02-07
author: KazooTTT
tags:
- npm
- node
published: true
slug: npm-registry
description: >-
本文介绍了如何查看、更换和取消Node.js包管理工具npm, yarn,
pnpm的源地址以及如何使用yrm工具快速切换不同的npm源。通过执行特定的命令用户可以轻松地管理这些工具的源设置从而优化包的下载速度和开发效率。
category: 前端
toAstro: true
---
# 查看源
```shell
npm config get registry
```
```shell
yarn config get registry
```
```shell
pnpm config get registry
```
# 换源
```shell
npm config set registry https://registry.npmmirror.com
```
```shell
yarn config set registry https://registry.npmmirror.com
```
```shell
pnpm config set registry https://registry.npmmirror.com
```
# 取消换源
```shell
npm config delete registry
```
```shell
yarn config delete registry
```
```shell
pnpm config delete registry
```
# 工具
[GitHub - i5ting/yrm: YARN registry manager, fast switch between different registries: npm, cnpm, nj, taobao](https://github.com/i5ting/yrm)
```shell
npm install -g yrm
yrm ls
yrm use [name]
```