# How best to use a custom module?

**URL:** <https://discourse.julialang.org/t/how-best-to-use-a-custom-module/77066>\
**Category:** General Usage\
**Tags:** question, modules, code-organization\
**Created:** [February 25, 2022, 1:28pm UTC](https://discourse.julialang.org/t/how-best-to-use-a-custom-module/77066 "2022-02-25T13:28:05Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [February 27, 2022, 5:37pm UTC](https://discourse.julialang.org/t/how-best-to-use-a-custom-module/77066/12 "2022-02-27T17:37:02Z")

</div>

The use of multiple includes is what’s causing the problem.

You could try this where they are all in the same source file

> [@Getting ERROR: LoadError: UndefVarError: Environment not defined when I try to use the modules I created](https://discourse.julialang.org/t/getting-error-loaderror-undefvarerror-environment-not-defined-when-i-try-to-use-the-modules-i-created/75559/2):
>
> Judicious use of import, using and export (the include makes no difference, it is just text subsitution) module Environment export Env mutable struct Env distance\_from\_pasture::Real trips\_milking\_parlor::Integer topography::String end end using .Environment export Env module Cows import ..Env export Cow mutable struct Cow environment::Env end end using .Cows export Cow e = Env(1, 1, "") c = Cow(e)

Or add moduleA to the Manifest of moduleB using Pkg.add(path=“/path/to/A”), create a project in a separate directory to include moduleA and moduleB as dependencies.

---

_[View the full topic](https://discourse.julialang.org/t/how-best-to-use-a-custom-module/77066)._
