从 asdf 迁移到 mise,免除头疼
发布: (2025年12月22日 GMT+8 16:05)
3 min read
原文: Dev.to
Source: Dev.to
1. 删除 asdf 插件并卸载 asdf
# remove plugins
asdf plugin list | xargs -n 1 asdf plugin remove
# uninstall asdf
brew uninstall asdf --force
brew autoremove
清理 .zshrc
# ASDF configuration
. "$BREW_PREFIX/opt/asdf/libexec/asdf.sh"
删除残留文件
rm -rf ~/.asdf
rm -rf ~/.tool-versions
确认 asdf 已被删除
brew list asdf
# Expected output:
# Error: No such keg: /opt/homebrew/Cellar/asdf
2. 安装 mise
- 项目页面:
- 入门指南:
brew install mise
验证安装
mise --version
_ __
____ ___ (_)_______ ___ ____ ____ / /___ _________
/ __ `__ \/ / ___/ _ \______/ _ \/ __ \______/ __ \/ / __ `/ ___/ _ \
/ / / / / / (__ ) __/_____/ __/ / / /_____/ /_/ / / /_/ / /__/ __/
/_/ /_/ /_/_/____/\___/ \___/_/ /_/ / .___/_/\__,_/\___/\___/
/_/ by @jdx
2025.12.12 macos-arm64 (2025-12-18)
将激活代码添加到你的 shell 配置中
(如有需要,将 zsh 替换为 bash 或 fish)
eval "$(mise activate zsh)"
3. 安装 mise 插件
在本例中我们安装 nodejs、pnpm、bun、yarn 和 python。
列出可用插件
mise plugins ls-remote
核心插件
mise plugins ls --core
# bun, deno, elixir, erlang, go, java, node, python, ruby, rust, swift, zig
检查可用版本
mise ls-remote node
mise ls-remote pnpm
mise ls-remote bun
mise ls-remote yarn
mise ls-remote python
安装特定版本
mise install node@22.21.1
mise install yarn@1.22.22
mise install pnpm@10.22.0
mise install bun@1.3.5
mise install python@3.12.12
或者使用 mise.toml 文件
在项目目录下创建 mise.toml:
[tools]
node = "22.21.1"
python = "3.12.12"
yarn = "1.22.22"
pnpm = "10.22.0"
如果遇到信任错误,运行:
mise trust
mise install
验证已安装的版本
yarn -v
# 1.22.22
node -v
# v22.21.1
python --version
# Python 3.12.12
如果出现 zsh: command not found: node,请确保在 .zshrc 中加入激活行:
eval "$(mise activate zsh)"
4. asdf → mise 命令映射
| asdf (modern) | mise equivalent | 备注 |
|---|---|---|
.tool-versions | mise.toml | 项目本地工具定义 |
asdf set | 编辑 mise.toml | 替代 asdf local/global |
asdf set -u | ~/.config/mise/config.toml | 用户/全局配置 |
asdf install | mise install | 安装所有已定义的工具 |
asdf exec | mise exec -- | 使用固定工具运行 |
asdf current | mise current | 显示当前活动的版本 |
asdf plugin add | (implicit) | mise 自动管理插件 |
asdf plugin list | mise ls | 列出已安装的工具 |
| shims | Shell 激活 (mise activate) | 基于 PATH 的 shim |
.asdf/installs | ~/.local/share/mise/installs | 工具的实际安装位置 |
.asdf/shims | ~/.local/share/mise/shims | 可执行的 shim 文件 |