mojo package

Compiles a Mojo package.


mojo package [options] <path>


Compiles a directory of Mojo source files into a binary package suitable to share and import into other Mojo programs and modules.

To create a Mojo package, first add an __init__.mojo file to your package directory. Then pass that directory name to this command, and specify the output path and filename with -o.

For more information, see Mojo modules and packages.


Output options

-o <PATH>

Sets the path and filename for the output package. The filename must end with either .mojopkg or .📦. The filename given here defines the package name you can then use to import the code (minus the file extension). If you don’t specify this option, output is written to stdout.

Compilation options

--no-optimization, -O0

Disables compiler optimizations. This might reduce the amount of time it takes to compile the Mojo source file. It might also reduce the runtime performance of the compiled executable.

--target-triple <TRIPLE>

Sets the compilation target triple. Defaults to the host target.

--target-cpu <CPU>

Sets the compilation target CPU. Defaults to the host CPU.

--target-features <FEATURES>

Sets the compilation target CPU features. Defaults to the host features.


Sets the architecture to generate code for.

-mcpu <CPU>

Sets the CPU to generate code for.

-mtune <TUNE>

Sets the CPU to tune code for.


Appends the given path to the list of directories to search for imported Mojo files.


Defines a named value that can be used from within the Mojo source file being executed. For example, -D foo=42 defines a name foo that, when queried with the sys.param_env module from within the Mojo program, would yield the compile-time value 42.


Parses the input file(s) as the Mojo standard library.

Diagnostic options


Emits warnings for missing or partial docstrings.

--max-notes-per-diagnostic <INTEGER>

When the Mojo compiler emits diagnostics, it sometimes also prints notes with additional information. This option sets an upper threshold on the number of notes that can be printed with a diagnostic. If not specified, the default maximum is 10.

Experimental compilation options

--debug-level <LEVEL>

Sets the level of debug info to use at compilation. The value must be one of: none (the default value), line-tables, or full. Please note that there are issues when generating debug info for some Mojo programs that have yet to be addressed.

--sanitize <CHECK>

Turns on runtime checks. The following values are supported: address (detects memory issues), and thread (detects multi-threading issues). Please note that these checks are not currently supported when executing Mojo programs.

Common options

--help, -h

Displays help information.