Elm“无法找到模块” [英] Elm "cannot find module"
问题描述
我在榆树市还很陌生。有趣的是,可以使用一种功能语言来开发前端的东西。现在,即使我很好地按照
也许它的行为与Haskell威胁模块的行为不同。
我该如何解决-很简单? -问题。
还是我的 elm-package.json
配置不正确?
更新为Elm 0.17
在0.17中,Html软件包已移至 elm-lang / html
。从终端运行以下命令进行安装:
elm软件包安装elm-lang / html
您还应该从<$ c中删除 evancz / elm-html
软件包$ c> elm-package.json ,因为从0.17开始它不再存在。
有关从0.16升级到0.17的更多信息,请参阅 0.17公告。
榆木0.16的原始答案
您的 elm-package.json
配置缺少< a href = http://package.elm-lang.org/packages/evancz/elm-html/latest> evancz / elm-html
软件包,它会显示 Html
。您可以使用elm的软件包管理器来安装依赖项,而不是直接编辑 elm-package.json
。
从终端,键入以下内容:
elm软件包安装evancz / elm-html
还将提示您安装 evancz / elm-html
所需的其他一些缺少的依赖项。运行此命令将更新您的 elm-package.json
文件,并从互联网上删除丢失的软件包并将其安装在标准的 elm-东西/软件包
目录。
您可以在 package.elm-lang.org 上在线浏览Elm软件包。边栏上的热门软件包部分包含此处提到的 evancz / elm-html
软件包。
I'm fairly new in Elm. It's interesting to see a functional language which allows you to develop front-end stuff. Now even if I am following the steps described here nicely, I still have problems with modules.
The code is
module Main where
import Html exposing ( Html )
import Signal
main : Signal Html.Html
main = Html.text "This should work."
|> Signal.constant
I have used elm-reactor -a='localhost'
to be able to view my output. But I am getting an error, that module 'HTML' cannot be found:
I cannot find find module 'Html'.
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
(note the double "find" hehe) The fix suggestion didn't help me. Or it could be that I'm not understanding the use of the .json file correctly.
elm-package.json:
{
"version": "1.0.0",
"summary": "testing elm",
"license": "BSD3",
"source-directories": [
".",
"./bin/"
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "3.0.0 <= v < 4.0.0"
},
"elm-version": "0.16.0 <= v < 0.17.0"
}
Here is a screenshot of my file tree.
Maybe it behaves differently than how Haskell is threatening the modules.
How can I solve this - eh simple? - problem.
Or is my elm-package.json
just configured incorrectly?
Update for Elm 0.17
In 0.17, the Html package has been moved to elm-lang/html
. Run the following command from the terminal to install it:
elm package install elm-lang/html
You should also remove the evancz/elm-html
package from elm-package.json
because it no longer exists as of 0.17.
For more information about the upgrading from 0.16 to 0.17, please see the 0.17 announcement.
Original Answer for Elm 0.16
Your elm-package.json
configuration is missing the evancz/elm-html
package, which exposes Html
. You can use elm's package manager to install dependencies rather than editing elm-package.json
directly.
From the terminal, type the following:
elm package install evancz/elm-html
You will also be prompted to install a few other missing dependencies required by evancz/elm-html
. Running this command will update your elm-package.json
file as well as pull down the missing packages from the internet and install them in the standard elm-stuff/packages
directory.
More info on the elm-package
tool can be found here.
You can browse elm packages online at package.elm-lang.org. The sidebar has a Popular Packages section which contains the evancz/elm-html
package mentioned here.
这篇关于Elm“无法找到模块”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!