Install Elm
- Linux - instructions
- Windows -
After installation is complete, open up the terminal on your computer. It may be called cmd.exe
or Command Prompt
on Windows.
Start by navigating to your desktop in the terminal:
The next step is to get familiar with elm
command. I personally had a really hard time learning terminal commands, so I worked hard to make the elm
command nice to use. Let’s go through a couple common scenarios.
You can start an Elm project by running:
Try running this command to create an elm.json
file and a src/
directory:
src/
holds all of your Elm files.
elm reactor
helps you build Elm projects without messing with the terminal too much. You just run it at the root of your project, like this:
This starts a server at http://localhost:8000
. You can navigate to any Elm file and see what it looks like. Run elm reactor
, follow the localhost link, and try to check out your src/Main.elm
file!
You can compile Elm code to HTML or JavaScript with commands like this:
Try running these commands on your src/Main.elm
file.
This is the most general way to compile Elm code. It is extremely useful once your project becomes too advanced for elm reactor
.
This command produces the same messages you have been seeing in the online editor and with elm reactor
. Years of work has gone into them so far, but please report any unhelpful messages . I am sure there are ways to improve!
Say you look around and decide you need and to make some HTTP requests. You can get them set up in your project with the following commands:
This adds these dependencies into your elm.json
file, making these packages available in your project. That will let you say import Http
and use functions like Http.get
in your programs.
First, do not worry about remembering all this stuff!
You can always run elm --help
to get a full outline of what elm
is capable of.
You can also run commands like elm make --help
and elm repl --help
to get hints about a specific command. This is great if you want to check which flags are available and what they do.
Second, do not worry if it takes some time to get comfortable with the terminal in general.
Now that we have our editor set up and available in the terminal, let’s get back to learning Elm!