外观
包管理器配置:NodeJS
| 包管理器 | 适用语言 | 主配置文件路径 | 官方首页 |
|---|---|---|---|
| npm | NodeJs | ~/.npmrc | www.npmjs.com |
| pnpm | NodeJs | ~/.config/pnpm/ | pnpm.io |
| yarn | NodeJs | ~/.yarnrc | yarnpkg.com |
npm
(1)使用 npm config 命令
shell
# 配置国内代理
npm config set registry https://registry.npmmirror.com
npm config get registry
# 配置包路径
npm config set prefix ${HOME}/.local
npm config get prefix
npm root -g
# 查看所有配置
npm config list
cat ~/.npmrc(2)编辑 ~/.npmrc 文件
shell
cat >> ~/.npmrc << EOF
disturl=https://npmmirror.com/mirrors/node
registry=https://registry.npmmirror.com
prefix=$HOME/.local
EOFpnpm
(1)使用 pnpm config 命令
shell
# 配置国内代理
pnpm config set registry https://registry.npmmirror.com
pnpm config get registry
# 查看所有配置
pnpm config list
cat ~/.config/pnpm/*上述命令会将配置写入 ~/.config/pnpm 目录。同时,~/.npmrc 中的部分通用配置也会生效,前者优先级更高。
(2)编辑 ~/.config/pnpm 目录下的文件
shell
mkdir -p ~/.config/pnpm
cat >> ~/.config/pnpm/auth.ini << EOF
registry=https://registry.npmmirror.com
EOFyarn
(1)使用 yarn config 命令
shell
# 配置国内代理
yarn config set registry https://registry.npmmirror.com
# 查看所有配置
yarn config list(2)编辑 ~/.yarnrc 文件
shell
cat >> ~/.yarnrc << EOF
registry "https://registry.npmmirror.com"
EOF