「ASDF」- 场景 | 方案

使用 | 安装 Node.js 程序

使用 asdf 工具,以安装 Node.js 为例

搜索是否存在 nodejs 插件

# asdf plugin list all | grep nodejs
nodejs                       *https://github.com/asdf-vm/asdf-nodejs.git

# --------------------------------------------------------- # 添加插件

apt-get install dirmngr gpg curl gawk # 查看插件仓库,安装相关依赖

asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin add nodejs # 或,因 nodejs 已存在于 Plugin Repo 中,所以可直接添加

# --------------------------------------------------------- # 查看插件版本

asdf list all nodejs # 查看所有可用版本。注意,需要 asdf plugin add 之后,才能查看。
asdf list all nodejs 14 # 查看子版本

# --------------------------------------------------------- # 安装特定版本插件

asdf install  nodejs latest # 安装最新版本

asdf current                # 查看当前版本

# --------------------------------------------------------- # 切换特定版本插件

asdf global nodejs latest
asdf local  nodejs latest # 当前目录遍历到根目录,根据最新找到的 .tool-versions 文件来确定版本。