module Myapp.Router.Helpers is not loaded and could not be found

I've seen this happening if one of the plugs imports MyApp.Router.Helpers, and is used in the MyApp.Router itself at the same time. This creates a compiler deadlock - in order to compile the router the plug is required, but in order to compile the plug, the router (and helper module) is required.

You can fix this by using fully qualified calls to the router helpers instead of importing them, i.e.

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

Got same error because of error in Absinthe Schema, forgot to alias some of used modules. Found it with rmarscher advice, commented all areas where MyAppWeb.Router.Helpers used and got real errors.


This also happened to me when one of my plugs contained an error and didn't compile. By commenting out the contents of my router and compiling again, I was able to see the compilation errors in my plug. After fixing them and uncommenting the contents of my router, it was able to compile normally.