2016-09-28 28 views
1

を見つけることができません。私はウェブサイト上のエルムのチュートリアルを追っていると私は、Mac上でそれを試してみました、それが働いていたが、私は、Linuxに移植するとき、それは私に次のエラーを与えたモジュール「ウィジェット」

- I cannot find module 'Widget'. 

Module 'Main' 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 

これは、使用されたコードであった:

main.elm

module Main exposing (..) 

import Html exposing (Html) 
import Html.App 
import Widget 


-- MODEL 


type alias AppModel = 
    { widgetModel : Widget.Model 
    } 


initialModel : AppModel 
initialModel = 
    { widgetModel = Widget.initialModel 
    } 


init : (AppModel, Cmd Msg) 
init = 
    (initialModel, Cmd.none) 



-- MESSAGES 


type Msg 
    = WidgetMsg Widget.Msg 



-- VIEW 


view : AppModel -> Html Msg 
view model = 
    Html.div [] 
     [ Html.App.map WidgetMsg (Widget.view model.widgetModel) 
     ] 



-- UPDATE 


update : Msg -> AppModel -> (AppModel, Cmd Msg) 
update message model = 
    case message of 
     WidgetMsg subMsg -> 
      let 
       (updatedWidgetModel, widgetCmd) = 
        Widget.update subMsg model.widgetModel 
      in 
       ({ model | widgetModel = updatedWidgetModel }, Cmd.map WidgetMsg widgetCmd) 



-- SUBSCIPTIONS 


subscriptions : AppModel -> Sub Msg 
subscriptions model = 
    Sub.none 



-- APP 


main : Program Never 
main = 
    Html.App.program 
     { init = init 
     , view = view 
     , update = update 
     , subscriptions = subscriptions 
     } 

widget.elm

module Widget exposing (..) 

import Html exposing (Html, button, div, text) 
import Html.Events exposing (onClick) 


-- MODEL 


type alias Model = 
    { count : Int 
    } 


initialModel : Model 
initialModel = 
    { count = 0 
    } 



-- MESSAGES 


type Msg 
    = Increase 



-- VIEW 


view : Model -> Html Msg 
view model = 
    div [] 
     [ div [] [ text (toString model.count) ] 
     , button [ onClick Increase ] [ text "Click" ] 
     ] 



-- UPDATE 


update : Msg -> Model -> (Model, Cmd Msg) 
update message model = 
    case message of 
     Increase -> 
      ({ model | count = model.count + 1 }, Cmd.none) 

これを修正する方法に関するヒントを教えてください。

+2

名前をWidget.elmに変更しようとしましたか? – Tosh

+0

Elmのソースコードが同じフォルダにない場合は、 'elm-package.json'をチェックして、[ここ]のように' source-directories'でそのフォルダを指定する必要があります。 (https://github.com/halfzebra/elm-examples/blob/master/examples/fractal-architecture/elm-package.json) – halfzebra

答えて

3

Linuxファイルシステムでは大文字と小文字が区別されるため、Elmファイルには、宣言したモジュールと同じ大文字小文字を使用する必要があります。あなたのケースではそう

Mainモジュールは "Main.elm" にする必要があります。

Widgetモジュールは「Widget.elm」にする必要があります。

関連する問題

 関連する問題