# "namespacing" and file/folders

**URL:** <https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411>\
**Category:** Learn\
**Created:** [November 1, 2018, 6:35pm UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411 "2018-11-01T18:35:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjfitzgibbons](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pjfitzgibbons/32/1456_2.png) [@pjfitzgibbons](https://discourse.elm-lang.org/u/pjfitzgibbons)\
**Post date:** [November 1, 2018, 6:35pm UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/1 "2018-11-01T18:35:32Z")

</div>

Hello,  
I am trying to apply “namespacing” to my app.

Inside ./src/Examples/RamdomDie.elm I have the example from [https://guide.elm-lang.org/effects/random.html](https://guide.elm-lang.org/effects/random.html) . The module starts with

```auto
module Examples.RandomDie exposing (main)

```

In index.html body I have  
`<script>var app = Elm.Examples.RandomDie.init({...`

Browser console has error :  
`Uncaught TypeError: Cannot read property 'RandomDie' of undefined`

Thoughts on what I have done wrong?

---

<div class="post-metadata">

**Author:** ![Sidney](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sidney/32/3290_2.png) [@Sidney](https://discourse.elm-lang.org/u/Sidney)\
**Post date:** [November 1, 2018, 6:41pm UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/2 "2018-11-01T18:41:13Z")

</div>

What _is_ defined on the `Elm` variable? Try logging it to the console in your browser.

---

<div class="post-metadata">

**Author:** ![pjfitzgibbons](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pjfitzgibbons/32/1456_2.png) [@pjfitzgibbons](https://discourse.elm-lang.org/u/pjfitzgibbons)\
**Post date:** [November 1, 2018, 6:50pm UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/3 "2018-11-01T18:50:28Z")

</div>

I just discovered my issue was with bad arguments on elm-live.

I was telling it to use src/\*.elm, which was not globbing down into src/Examples, even though the elm-live output ends a startup with

```auto
 elm-live:
  Watching src/**/*.elm.

```

So, that’s confusing on elm-live.  
Anyway, seems to be working now with this command

```auto
elm-live src/**/*.elm --open --start-page=index.html -- --output=main.js

```

---

<div class="post-metadata">

**Author:** ![Sidney](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sidney/32/3290_2.png) [@Sidney](https://discourse.elm-lang.org/u/Sidney)\
**Post date:** [November 1, 2018, 6:54pm UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/4 "2018-11-01T18:54:11Z")

</div>

Great, glad to hear it’s working. You might want to open an issue for elm-live, if that message isn’t accurate.

---

<div class="post-metadata">

**Author:** ![alexkorban](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/alexkorban/32/3242_2.png) [@alexkorban](https://discourse.elm-lang.org/u/alexkorban)\
**Post date:** [November 2, 2018, 12:55am UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/5 "2018-11-02T00:55:27Z")

</div>

Since I’m the author of that log line in `elm-live`, I thought I’d chime in 🙂

`elm-live` picks up the directories it’s going to watch from your `elm.json`. The log line correctly says that it’s going to watch for file changes recursively in `src`. _But_, you’re supposed to give it the name of your **main module** as the first argument, `src/Examples/RandomDie.elm` in your case. It’s very curious that it somehow works with `src/**/*.elm` instead.

---

<div class="post-metadata">

**Author:** ![malaire](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@malaire](https://discourse.elm-lang.org/u/malaire)\
**Post date:** [November 2, 2018, 1:00am UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/6 "2018-11-02T01:00:03Z")

</div>

> [@alexkorban](#):
>
> _But_ , you’re supposed to give it the name of your **main module** as the first argument

So `elm-live` doesn’t support having multiple main modules?

---

<div class="post-metadata">

**Author:** ![alexkorban](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/alexkorban/32/3242_2.png) [@alexkorban](https://discourse.elm-lang.org/u/alexkorban)\
**Post date:** [November 2, 2018, 1:34am UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/7 "2018-11-02T01:34:52Z")

</div>

Apparently it does. Just tried it with `elm-live src/Main1.elm src/Main2.elm -- --output elm.js`.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [November 12, 2018, 1:37am UTC](https://discourse.elm-lang.org/t/namespacing-and-file-folders/2411/8 "2018-11-12T01:37:16Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
