Mit mojo run ausführen
Führen Sie ein Programm über die Kommandozeile aus.
Mit mojo run ausführen ist eine kostenlose Mojo Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Mojo Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
From File to Running Program
You have a saved hello.mojo file. To see it work, you launch it from your terminal with the mojo command. 🖥️
The mojo run Command
The simplest way to execute a file is mojo run followed by the file name. Mojo compiles and runs it in one step.
mojo run hello.mojoRun from the Right Folder
Open your terminal in the folder that holds the file, or give the full path. Otherwise Mojo cannot find hello.mojo to run.
cd my_project
mojo run hello.mojoSee Your Output
After you press enter, Mojo prints the program's output right in the terminal. Your greeting appears on the next line.
Hello, world!The Shorter Form
You can often drop the word run and just pass the file: mojo hello.mojo does the same thing as mojo run.
mojo hello.mojoEdit, Save, Run Again
Change the code, save, and run the command again to see new output. This quick loop is how you learn fast in Mojo.
Reading an Error Message
If you have a typo, Mojo stops and prints an error with the line number. Read it, fix that line, and run once more.
Run Just Checks for main
mojo run expects your file to have a main function. Without one, it has nothing to start, and you get a clear error.
Building an Executable
For a faster standalone program, mojo build creates an executable file you can run directly, without compiling each time.
mojo build hello.mojorun vs build
Use run while learning and iterating, since it is one quick step. Reach for build when you want a finished binary to ship or reuse.
Your Workflow Is Set
Write code, save the file, type mojo run, read the output. That short cycle is the core habit of every Mojo session.
Quick Check
You want to compile and execute hello.mojo in a single terminal step. Which command does that?
Recap
Use mojo run from the file's folder to compile and execute in one step, read the output, then edit and run again. 🎯
Häufig gestellte Fragen
Ist die Lektion „Mit mojo run ausführen“ kostenlos?
Ja — der vollständige Text von „Mit mojo run ausführen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Mojo Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Mojo Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Mit mojo run ausführen“?
Führen Sie ein Programm über die Kommandozeile aus. Du übst Mojo Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Mojo Academy zu starten?
Keine Vorkenntnisse erforderlich. Mojo Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.
Wie lange dauert die Lektion „Mit mojo run ausführen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Mojo Academy-Lektion Code schreiben und ausführen?
Ja. Jede Mojo Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Ihre erste .mojo-Datei
- Der main-Einstiegspunkt
- Mit mojo run ausführen
- Im Mojo-REPL experimentieren