mise
字数: 0 字 时长: 0 分钟
https://mise.jdx.dev/installing-mise.html
使用体验
管理
node rust java go
不建议管理
python
,会导致pip
命令无效,需要使用python -m pip
才能使用。
command
sh
mise use -g python
mise uninstall python
# 列出注册表中的所有工具 https://mise.jdx.dev/registry.html#tools
mise registry
# 配置文件及其优先级顺序
mise config
# 查看远程可用版本
mise ls-remote node # 列出所有可用的 Node.js 版本
mise ls-remote python # 列出所有可用的 Python 版本
# 查看已安装的版本
mise ls node # 查看已安装的 Node.js 版本
mise ls # 查看所有工具的已安装版本
# 安装特定版本
mise install node@18.12.0 # 安装指定版本的 Node.js
mise install python@3.10.0 # 安装指定版本的 Python
# 设置版本
mise use --global node@18.12.0 # 设置全局默认版本
mise use node@18.12.0 # 设置当前项目的版本
mise use node@lts # 使用 LTS 版本
# 查看当前配置
mise settings # 查看所有设置
# 新项目初始化:
# 进入新项目目录
cd my-new-project
# 设置项目所需的 Node.js 版本
mise use node@18.12.0
# 现在项目就会使用 Node.js 18.12.0
node --version # 输出:v18.12.0
# 多项目切换:
# 项目 A 使用 Node.js 18
cd project-a
mise use node@18.12.0
# 项目 B 使用 Node.js 16
cd project-b
mise use node@16.19.0
mise.toml
yaml
[tools]
node = "22.9.0"
python = "3.10.0"
[env]
NODE_ENV = "development"
PYTHONPATH = "${PWD}/src"
[tasks]
start = "npm start"
test = "pytest tests/"
deploy = "bash ./scripts/deploy.sh"
sh
mise install
mise run test
CI/CD 集成
yaml
# GitHub Actions 示例
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jdx/mise-action@v2
- run: mise install
- run: mise run test
window
PowerShell环境下执行
安装 Scoop
sh
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
安装 mise
都执行一遍后,重新打开终端
sh
scoop install mise
# 修正不需要 mise exec
$shimPath = "$env:USERPROFILE\AppData\Local\mise\shims"
$currentPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$newPath = $currentPath + ";" + $shimPath
[Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
# create profile if it doesn't already exist
if (-not (Test-Path $profile)) { New-Item $profile -Force }
# open the profile
Invoke-Item $profile
安装版本
sh
mise use --global node@22
# 这个命令在执行完上面两句后没必要用 mise exec -- 了
mise exec -- node my-script.js
mise use -g python
mise use -g go
mise use -g rust
mise use -g node@16
mise use -g node@18
mise use -g java@21
mise use -g java@17
mise use -g java@8