"module is not available"-error when calling a module inside mix.exs

When mix.exs is evaluated your application is not available, as your application is built using the evaluation result of the mix.exs.

So by requiring your applications code within mix.exs you are creating a circular dependency that your application needs to be compiled in order to get compiled.