1. Overview
2. Windows 2.1. fnm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 winget install -e --id Schniz.fnmAdd-Content -Path $PROFILE -Value @' # fnm $env:FNM_NODE_DIST_MIRROR = "https://mirrors.aliyun.com/nodejs-release/" fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression $env:ELECTRON_MIRROR = "https://npmmirror.com/mirrors/electron/" '@ fnm use --install-if-missing 22 npm config set registry https://registry.npmmirror.com
2.2. bun 安装 1 powershell -c "irm bun.sh/install.ps1|iex"
设置国内源 1 2 3 4 Add-Content -Path $PROFILE -Value @' $env:BUN_CONFIG_REGISTRY = "https://registry.npmmirror.com" '@
3. Linux/WSL 3.1. fnm 安装 1 curl -fsSL https://fnm.vercel.app/install | bash
设置国内源 for bash
$HOME/.bashrc
1 2 export FNM_NODE_DIST_MIRROR="https://mirrors.aliyun.com/nodejs-release/" export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
for fish
$HOME/.config/fish/conf.d/fnm.fish
1 2 set -x FNM_NODE_DIST_MIRROR "https://mirrors.aliyun.com/nodejs-release/" set -x ELECTRON_MIRROR "https://npmmirror.com/mirrors/electron/"
打开新终端
1 2 3 4 5 fnm use --install-if-missing 22 npm config set registry https://registry.npmmirror.com
3.2. bun 安裝 1 curl -fsSL https://bun.com/install | bash
设置国内源 for bash
$HOME/.bashrc
1 export BUN_CONFIG_REGISTRY="https://registry.npmmirror.com"
for fish
$HOME/.config/fish/config.fish
1 set -x BUN_CONFIG_REGISTRY "https://registry.npmmirror.com"
npx/npm 别名 在fish下,可以通过abbr命令添加别名,将npx和npm指向bunx和bun。
1 2 3 abbr -a -- npx bunx abbr -a -- npm bun abbr >> ~/.config/fish/conf.d/fnm.fish