Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.npmrc 学习笔记 #24

Open
maomao1996 opened this issue Nov 18, 2021 · 0 comments
Open

.npmrc 学习笔记 #24

maomao1996 opened this issue Nov 18, 2021 · 0 comments
Labels
nodejs nodejs 相关

Comments

@maomao1996
Copy link
Owner

maomao1996 commented Nov 18, 2021

.npmrc 学习笔记

.npmrcnpm 配置文件,可以通过修改配置项对 npm 做配置

🌰: 修改镜像源

registry=https://registry.npmmirror.com
# 查看所有配置
npm config ls [-l|--json]

# 查看配置
npm config get <key>
#OR
npm get <key>

# 查看配置
npm config delete <key>

# 修改配置
npm config set <key> <value>
#OR
npm set <key> <value>

# 编辑配置文件
npm config edit [-g|--global]

配置说明

配置读取顺序

  1. 命令行
  2. 项目配置(项目根目录下的 npmrc 文件)
  3. 用户配置(用 npm config get userconfig 查看文件位置)
  4. 全局配置(用 npm config get prefix 查看文件位置)
  5. 默认配置

其他包管理器

yarn

  • yarn 1 使用 .yarnrc.npmrc 文件
  • yarn 2 使用 .yarnrc.yml 文件(不再使用 .yarnrc.npmrc)

踩坑点

yarn 1 中如果同时存在 .yarnrc.npmrc 文件时, .npmrc 优先级高于 .yarnrc
当我们使用 yarn 1 时项目只需要配置 .npmrc 文件

pnpm

pnpm 使用 .npmrc 文件

@maomao1996 maomao1996 added the nodejs nodejs 相关 label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nodejs nodejs 相关
Projects
None yet
Development

No branches or pull requests

1 participant