← 返回命令列表

Linux command

mix 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create a new project

mix new [project_name]

Fetch dependencies

mix deps.get

Compile the project

mix compile

Run tests

mix test

Start an interactive shell with the project loaded

iex -S mix

Format source files

mix format

Build a production release

mix release

List all available tasks

mix help

说明

mix is the build tool that ships with Elixir. It manages project creation, dependency resolution, compilation, testing, code formatting, and releases. All functionality is exposed through a task-based system where each `mix task` maps to a Mix.Task module. Dependencies are declared in `mix.exs` and fetched from the Hex package manager. The active environment is controlled by the `MIX_ENV` variable, which defaults to `dev` (and `test` when running `mix test`). Custom tasks can be created by defining modules under `Mix.Tasks.*`.

参数

new _NAME_
Create a new Elixir project in a directory named _NAME_.
deps.get
Fetch all project dependencies listed in `mix.exs`.
deps.compile
Compile fetched dependencies.
deps.update _DEP_
Update a specific dependency (or `--all` to update all).
compile
Compile the current project and its dependencies.
test
Run the project's test suite.
format
Format Elixir source files according to the standard formatter.
run _FILE_
Execute a script or expression within the project context.
clean
Remove build artifacts.
release
Assemble a self-contained release for deployment.
do _task1_, _task2_
Run multiple tasks sequentially in one command.
help _TASK_
List all available tasks, or show help for a specific task.

FAQ

What is the mix command used for?

mix is the build tool that ships with Elixir. It manages project creation, dependency resolution, compilation, testing, code formatting, and releases. All functionality is exposed through a task-based system where each `mix task` maps to a Mix.Task module. Dependencies are declared in `mix.exs` and fetched from the Hex package manager. The active environment is controlled by the `MIX_ENV` variable, which defaults to `dev` (and `test` when running `mix test`). Custom tasks can be created by defining modules under `Mix.Tasks.*`.

How do I run a basic mix example?

Run `mix new [project_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does new _NAME_ do in mix?

Create a new Elixir project in a directory named _NAME_.