Skip to content

fnm 速查 ​

fnm 是轻量的 Node.js 版本管理器,适合多项目切换版本。

安装 ​

bash
curl -fsSL https://fnm.vercel.app/install | bash

安装后重新打开终端,或手动加载:

bash
source ~/.bashrc
source ~/.zshrc
source ~/.config/fish/config.fish

常用命令 ​

用途命令
查看 fnmfnm --version
安装 LTSfnm install --lts
使用 LTSfnm use lts-latest
默认 LTSfnm default lts-latest
查看远程版本fnm ls-remote
安装指定版本fnm install 20
使用指定版本fnm use 20
默认指定版本fnm default 20
查看已安装版本fnm list
查看当前版本fnm current
按 .node-version / .nvmrc 切换fnm use

验证 ​

用途命令
Node 版本node -v
npm 版本npm -v
Node 路径which node
npm 路径which npm

排查 ​

  • fnm: command not found:重新加载 shell 配置或重开终端
  • node -v 没变化:执行 fnm use lts-latest
  • 多来源冲突:检查 which node,尽量不要混用系统级 Node

上次更新于: