mojo runで実行する
コマンドラインからプログラムを実行します
「mojo runで実行する」はCoddyKit上の無料Mojo Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMojo Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Mojo Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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. 🎯
よくある質問
「mojo runで実行する」レッスンは無料ですか?
はい。「mojo runで実行する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Mojo Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Mojo Academyコースには全4レッスンが含まれています。
「mojo runで実行する」で何を学びますか?
コマンドラインからプログラムを実行します ブラウザで直接実行するハンズオンコードでMojo Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Mojo Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMojo Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「mojo runで実行する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMojo Academyレッスンでコードを書いて実行できますか?
はい。すべてのMojo Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 初めての.mojoファイル
- mainエントリーポイント
- mojo runで実行する
- Mojo REPLで試す