Linux command
elixir 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Run Elixir script
elixir [script.exs]
Evaluate expression
elixir -e "[IO.puts \"Hello\"]"
Start with shell
elixir -S iex
Run with Mix
elixir -S mix run
Start named node
elixir --name [node@host] -S iex
Set environment
MIX_ENV=prod elixir -S mix phx.server
说明
elixir runs Elixir code and scripts. It's the primary command for executing Elixir programs, supporting both script files (.exs) and compiled modules. The command starts the Erlang VM with Elixir loaded. Options control distributed computing settings, code loading, and execution mode. Combined with `-S mix`, it runs Mix tasks. Elixir's interactive shell (IEx) can be started using `elixir -S iex` for development and debugging.
参数
- -e _CODE_
- Evaluate code string.
- -r _FILE_
- Require file before execution.
- -S _SCRIPT_
- Run Erlang/Elixir script.
- --name _NAME_
- Set distributed node name.
- --sname _NAME_
- Set short node name.
- --cookie _COOKIE_
- Set Erlang distribution cookie.
- --help
- Display help information.
FAQ
What is the elixir command used for?
elixir runs Elixir code and scripts. It's the primary command for executing Elixir programs, supporting both script files (.exs) and compiled modules. The command starts the Erlang VM with Elixir loaded. Options control distributed computing settings, code loading, and execution mode. Combined with `-S mix`, it runs Mix tasks. Elixir's interactive shell (IEx) can be started using `elixir -S iex` for development and debugging.
How do I run a basic elixir example?
Run `elixir [script.exs]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -e _CODE_ do in elixir?
Evaluate code string.