Hi,
I am confused. I have code like this:
BannersView.elm:
module Banners.View exposing (view)
– …
Main.elm:
– …
import Banners.View
– …
Banners.View.view …
This produces the following error at compile time:
I cannot find module ‘Banners.View’.
Module ‘ZKMain’ is trying to import it.
Potential problems could be:
- Misspelled the module name
- Need to add a source directory or new dependency to elm-package.json
However, if I remove the dot from the module name (i.e. name it BannersView), everything compiles fine.
Is there some trick in elm-package.json to make the name with a dot work correctly?
Best,
Michal
1 Like
In Elm, the module name needs to be the same as the file name, and the prefixes need to be the same as the path of the file within a source directory.
If you want your module to be named Banners.View
, you’ll need to name the file View.elm
and place it in a folder named Banners
within a source directory:
.
| - src
| | - Banners
| | | - View.elm
| |
| | - Main.elm
|
| - elm-package.json
4 Likes
Hi,
Thanks! I expected something of the kind, but couldn’t find any documentation.
So it won’t work even if I name the file Banners.View.elm?
I’ll just keep the name without the dot, then, because the file resides in directory called Pages which makes more sense to me
Best,
Michal