2016-11-12 83 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

這也發生在我身上時,我插頭的一個包含一個錯誤,並沒有編譯。通過評論我的路由器的內容並重新編譯,我能夠看到我的插件中的編譯錯誤。修復它們並取消我的路由器的內容後,它能夠正常編譯。