Here’s what you need to do in order to run Elm locally:

1. Install elm

This can be done via npm, assuming you are operating on a unix system and have node installed.

npm install -g elm

You can test if the installation was successful by running:

elm

You should see a help output that shows elm version and commands.

2. Create a directory for your new project

mkdir -p ~/apps/elm/hello-world && cd $_

3. Create your elm program

Let’s just take the example from the elm-lang homepage and create a file Main.elm with the following content:

The main program is simply a span element with class “welcome-message” and a “Hello, World!” text node as child, so basically it will just resolve to <span class=”welcome-message”>Hello, World!</span>.

4. Compile your program

This can be done with the elm-make tool which comes shipped with elm:

elm make Main.elm --output app.js

Elm will probably tell you that some packages are needed and ask to upgrade these which you can approve.

However, the compiler will still complain that it cannot find the Html module, which we are trying to import in our Main.elm file. This leads us directly to the next step:

5. Install missing dependencies

To find the required Html module you can visit http://package.elm-lang.org and search for “Html”. There are multiple candidates in the search result coming up, but we need the elm-lang/html package. You can go ahead and install it with:

elm package install elm-lang/html

Approve the upgrade plan including the sub-dependent virtual-dom module. If we run the elm make command above again, it should succeed this time.

Notice that elm created an elm-package.json as well as an elm-stuff directory in your project folder. That’s quite similar to node’s package.json and the node_modules folder.

6. Create a HTML file to embed your elm code

Now we can create a simple index.html file to include your compiled app.js and start up the application: