2017-02-15 66 views
2

這裏是我的項目的榆樹的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出口名爲Chart模塊。

在我ChartView.elm我想導入Chart

module Components.ChartView exposing (..) 

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

但當榆樹嘗試編譯,我得到的錯誤:

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 

,如果我從項目目錄中打開榆樹REPL,我可以如預期的進口圖:

[email protected]:~/elixir/eval$ elm repl 
\> import Chart 
\> 

任何想法爲什麼我編譯時榆樹不能'查找圖表'?

+2

ChartView.elm是在一個子目錄中,還是坐在'elm-package.json'旁邊?你有可能鏈接你的Git倉庫,以便我們克隆它並看看? –

+0

你是否運行了'elm-package install -y',以便下載庫? –

+0

是的,我做了elm-package安裝。當從項目的頂級目錄 – CHsurfer

回答

2

儘管已經在評論中解決了這個問題,但還沒有人將其寫入答案。 Elm將不會從嵌套目錄中找到相關性:您想在與elm-package.jsonelm-stuff目錄的相鄰位置)相同的目錄中運行elm repl。這聽起來像你在web/elm/目錄中想要的文件在你的應用程序的頂層。

+0

這是一個無償的答案,但我想我們可以避免人們考慮這個問題,認爲它沒有答案。 – Charlie