How to call a module from another file into the current working file?

Basically, I have this module called MyModule in a file called mymodule.exs. Now, I want to call this module and use its functions in another file containing the module NewModule.

I tried using alias MyModule and then tried calling MyModule.myfunction(), however, I get the error (module MyModule is not available).

There is also a thing called Code.require_file, however, I couldn’t understand how that works or if that is even applicable over here as well.

Any help will be largely appreciated. Thank you!

Maybe you need to rename mymodule.exs to my_module.ex (well, the underscore is only a convention that you don’t have to follow. It’s the extension .ex that matters).

By default, the .ex files are compiled by mix, but the .exs files are not.

After renaming the file, actually you don’t have to do anything special.


Yeah, the issue was actually with the name of the file. Apologies for taking your time but thank you for this!.

Anytime :smiley: