这是我的项目' 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
导出名为Chart
的模块。
在我的ChartView.elm
我要导入Chart
module Components.ChartView exposing ( .. )
import Chart as C exposing ( .. )
import Html exposing ( Html, div )
import Html.Attributes exposing ( id, class )
但是当elm尝试编译时,我收到错误:
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
如果我从项目目录中打开elm repl,我可以按预期导入Chart:
jon@jon-Xubuntu-VB:~/elixir/eval$ elm repl
\> import Chart
\>
为什么我榆树无法找到图表&#39;什么时候编译?
答案 0 :(得分:2)
虽然这已在评论中得到解决,但还没有人在答案中写到这一点。
Elm不会从嵌套目录中找到依赖项:您希望在与elm repl
相同的目录中运行elm-package.json
(与elm-stuff
目录相邻)。听起来你错误地在应用程序的顶层有一个elm-package.json
文件,当你想要它在web/elm/
目录中时。