2016-11-12 104 views
4

编译错误在药剂/凤凰应用:模块Myapp.Router.Helpers未加载,无法找到

== Compilation error on file web/views/layout_view.ex == 
** (CompileError) web/views/layout_view.ex:2: module Myapp.Router.Helpers is not loaded and could not be found 
    expanding macro: Myapp.Web.__using__/1 
    web/views/layout_view.ex:2: Myapp.LayoutView (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/views/layout_view.ex:2: Myapp.LayoutView (module) 
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1 

我web.ex是一个标准,它不是什么新鲜事。

回答

13

如果其中一个插头导入MyApp.Router.Helpers,并且同时在MyApp.Router本身中使用,我已经看到了这种情况。这会造成编译器死锁 - 为了编译需要插件的路由器,但为了编译插件,需要路由器(和辅助模块)。

您可以通过使用完全合格的呼叫路由器的帮手,而不是进口他们解决这个问题,即

alias MyApp.Router.Helpers, as: Routes 
Routes.foo_path(conn, :create) 
4

这也发生在我身上时,我插头的一个包含一个错误,并没有编译。通过评论我的路由器的内容并重新编译,我能够看到我的插件中的编译错误。修复它们并取消我的路由器的内容后,它能够正常编译。