CHsurfer
CHsurfer

Reputation: 1414

Elm cannot find Module that is in a dependancy

Here is my project's elm-package.json

{
  "version": "1.0.0",
  "summary": "helpful summary of your project, less than 80 characters",
  "repository": "https://github.com/user/project.git",
  "license": "BSD3",
  "source-directories": [
      "."
  ],
  "exposed-modules": [],
  "dependencies": {
    "elm-lang/core": "5.1.1 <= v < 6.0.0",
    "elm-lang/html": "2.0.0 <= v < 3.0.0",
    "simonh1000/elm-charts": "3.1.0 <= v < 4.0.0"
  },
  "elm-version": "0.18.0 <= v < 0.19.0"
}

elm-charts exports a module called Chart.

In my ChartView.elm I want to import Chart

module Components.ChartView exposing ( .. )

import Chart as C exposing ( .. )
import Html exposing ( Html, div )
import Html.Attributes exposing ( id, class )

but when elm tries to compile, I get the error:

I cannot find module 'Chart'.

Module 'Components.ChartView' 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

if I open elm repl from the project directory, I can import Chart as expected:

jon@jon-Xubuntu-VB:~/elixir/eval$ elm repl
\> import Chart
\>

any ideas why I Elm can't 'find Chart' when compiling?

Upvotes: 2

Views: 1810

Answers (1)

Charlie
Charlie

Reputation: 705

Though this has been resolved in comments, no one has written this in an answer yet. Elm will not find dependencies from nested directories: you want to run elm repl in the same directory as your elm-package.json (adjacent to the elm-stuff directory). It sounds like you mistakenly have an elm-package.json file at the top level of your app, when you wanted it in the web/elm/ directory.

Upvotes: 2

Related Questions