# \#modules

**URL:** https://discourse.julialang.org/tag/modules/917.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [How to organize modules in a composable way?](https://discourse.julialang.org/t/how-to-organize-modules-in-a-composable-way/134536)

<div class="topic-metadata">

**Author:** [@mj2984](https://discourse.julialang.org/u/mj2984)\
**Replies:** 6\
**Last updated:** [December 16, 2025, 7:46am UTC](https://discourse.julialang.org/t/how-to-organize-modules-in-a-composable-way/134536 "2025-12-16T07:46:04Z")

</div>

Suppose I have a module module\_init that defines a type init\_struct, and I am now trying to make multiple modules in different projects that build on top of this init\_struct. For example ./project\_init/src/module\_init.j…

---

## [Programmatically defining a global variable in a new module](https://discourse.julialang.org/t/programmatically-defining-a-global-variable-in-a-new-module/133188)

<div class="topic-metadata">

**Author:** [@Marco\_Lombardi](https://discourse.julialang.org/u/Marco_Lombardi)\
**Replies:** 17\
**Last updated:** [October 21, 2025, 5:10pm UTC](https://discourse.julialang.org/t/programmatically-defining-a-global-variable-in-a-new-module/133188 "2025-10-21T17:10:59Z")

</div>

I need to be able to programmatically define a new global variable in a module. Till Julia v1.11 I was able to do this as function define\_global() m = Module(:MyModule) Core.eval(m, :(global data)) setglobal…

---

## [Problems about using modules in same file](https://discourse.julialang.org/t/problems-about-using-modules-in-same-file/129865)

<div class="topic-metadata">

**Author:** [@Cyan](https://discourse.julialang.org/u/Cyan)\
**Replies:** 4\
**Last updated:** [June 14, 2025, 4:10am UTC](https://discourse.julialang.org/t/problems-about-using-modules-in-same-file/129865 "2025-06-14T04:10:57Z")

</div>

I tried code like this module moduleA function f1() println("test") end end module moduleB function f2() moduleA.f1() end end moduleB.f2() but it turned out ERROR: UndefVarError: \`mod…

---

## [About module importation](https://discourse.julialang.org/t/about-module-importation/127164)

<div class="topic-metadata">

**Author:** [@Gesee](https://discourse.julialang.org/u/Gesee)\
**Replies:** 5\
**Last updated:** [March 20, 2025, 10:40pm UTC](https://discourse.julialang.org/t/about-module-importation/127164 "2025-03-20T22:40:17Z")

</div>

If I have a module A importing a package B and a module C importing the package B, How can do to import the module B only one time so that module A and module C can use it

---

## [I get errors when using module](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351)

<div class="topic-metadata">

**Author:** [@Fahim](https://discourse.julialang.org/u/Fahim)\
**Replies:** 3\
**Last updated:** [February 3, 2025, 4:24pm UTC](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351 "2025-02-03T16:24:14Z")

</div>

Dear Julia friends, First of all, I apologize for my poor English skills. I have a problem developing a module that uses Embeddings.jl: module Portal include("./t.jl") export get\_embedding end # module Portal using Em…

---

## [Multiple Julia processes while using Modules](https://discourse.julialang.org/t/multiple-julia-processes-while-using-modules/75071)

<div class="topic-metadata">

**Author:** [@roh\_codeur](https://discourse.julialang.org/u/roh_codeur)\
**Replies:** 6\
**Last updated:** [October 26, 2024, 9:32am UTC](https://discourse.julialang.org/t/multiple-julia-processes-while-using-modules/75071 "2024-10-26T09:32:10Z")

</div>

Hi Following my discussion from the below thread, I have been trying out 2 approaches to evaluate Julia project organisation approaches. Creating files as modules and “using” them in other files Creating them as ind…

---

## [Best practise: organising code in Julia](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362)

<div class="topic-metadata">

**Author:** [@roh\_codeur](https://discourse.julialang.org/u/roh_codeur)\
**Replies:** 11\
**Last updated:** [October 26, 2024, 9:13am UTC](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362 "2024-10-26T09:13:55Z")

</div>

Hi A newbie here, from OOP background. I am looking to put together a project which will: Download data from Internet Do some manipulations on the downloaded data Do some analysis on the downloaded data Please note t…

---

## [What is the preferred way to use multiple files?](https://discourse.julialang.org/t/what-is-the-preferred-way-to-use-multiple-files/30687)

<div class="topic-metadata">

**Author:** [@EvgeniyMist](https://discourse.julialang.org/u/EvgeniyMist)\
**Replies:** 15\
**Last updated:** [October 25, 2024, 3:06pm UTC](https://discourse.julialang.org/t/what-is-the-preferred-way-to-use-multiple-files/30687 "2024-10-25T15:06:59Z")

</div>

I wanted to structure my code by dividing it into several files. But I ran into some problem. So, in its simplest form, I have 3 files: main.jl module main include("structs.jl") include("functions.jl") first\_point =…

---

## [How to use local, relative modules (best practice, simple)?](https://discourse.julialang.org/t/how-to-use-local-relative-modules-best-practice-simple/81634)

<div class="topic-metadata">

**Author:** [@jakob1](https://discourse.julialang.org/u/jakob1)\
**Replies:** 15\
**Last updated:** [October 22, 2024, 9:56am UTC](https://discourse.julialang.org/t/how-to-use-local-relative-modules-best-practice-simple/81634 "2024-10-22T09:56:41Z")

</div>

Hi, Julia states to feel like a scripting language. Hence I would like to find out the most simple way to modularize (smaller) projects in julia. Here is a minimal example that worked for me after some research and tri…

---

## [When to define a \`module\`](https://discourse.julialang.org/t/when-to-define-a-module/120935)

<div class="topic-metadata">

**Author:** [@Santiago\_Lopez](https://discourse.julialang.org/u/Santiago_Lopez)\
**Replies:** 22\
**Last updated:** [October 6, 2024, 11:20pm UTC](https://discourse.julialang.org/t/when-to-define-a-module/120935 "2024-10-06T23:20:53Z")

</div>

When developing a package (call it MyPackage) one usually has a “main” function src/MyPackage.jl. This file is a module with a bunch of using, export and include statements. The export statements establish the API of th…

---

## [Module parameters and run-time efficiency](https://discourse.julialang.org/t/module-parameters-and-run-time-efficiency/119505)

<div class="topic-metadata">

**Author:** [@jhidding](https://discourse.julialang.org/u/jhidding)\
**Replies:** 3\
**Last updated:** [September 17, 2024, 3:17pm UTC](https://discourse.julialang.org/t/module-parameters-and-run-time-efficiency/119505 "2024-09-17T15:17:57Z")

</div>

Hi, I want to perform dispatch based on functions of the same name within a module. There’s two ways to go about it: having a function f(m::Module,...) or defining a trait type and saying f(::Type{Mod{M}}, ...) where M. …

---

## [PSA: Use modules for dirty work preparing scripts, debugging, etc](https://discourse.julialang.org/t/psa-use-modules-for-dirty-work-preparing-scripts-debugging-etc/119068)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 3\
**Last updated:** [September 6, 2024, 12:01am UTC](https://discourse.julialang.org/t/psa-use-modules-for-dirty-work-preparing-scripts-debugging-etc/119068 "2024-09-06T00:01:55Z")

</div>

Let’s say I’m preparing a script, e.g. to analyze data in a project. The recommended practice is to put as much code as possible in functions, keeping the global scope clean. But while I’m designing those functions (or d…

---

## [Using everything exported in a module and its submodules](https://discourse.julialang.org/t/using-everything-exported-in-a-module-and-its-submodules/117024)

<div class="topic-metadata">

**Author:** [@K5Julien](https://discourse.julialang.org/u/K5Julien)\
**Replies:** 4\
**Last updated:** [July 14, 2024, 10:28am UTC](https://discourse.julialang.org/t/using-everything-exported-in-a-module-and-its-submodules/117024 "2024-07-14T10:28:12Z")

</div>

I am currently replacing some String arguments of my mutable structure with dedicated types instead. The following MWE works perfectly fine: module MyPackage ### Some code module Options module SolveMod …

---

## [Multimodule project: Error when calling function from imported module in Julia](https://discourse.julialang.org/t/multimodule-project-error-when-calling-function-from-imported-module-in-julia/113045)

<div class="topic-metadata">

**Author:** [@dmgcodevil](https://discourse.julialang.org/u/dmgcodevil)\
**Replies:** 1\
**Last updated:** [April 17, 2024, 7:52am UTC](https://discourse.julialang.org/t/multimodule-project-error-when-calling-function-from-imported-module-in-julia/113045 "2024-04-17T07:52:28Z")

</div>

I’m new to Julia. I want to organize my code into modules. I have three modules: ModuleA.jl : module ModuleA include("ModuleB.jl") export process using .ModuleB function process(foo::Foo) end end ModuleB.jl : modul…

---

## [Code Organization](https://discourse.julialang.org/t/code-organization/112314)

<div class="topic-metadata">

**Author:** [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Replies:** 20\
**Last updated:** [April 5, 2024, 1:24am UTC](https://discourse.julialang.org/t/code-organization/112314 "2024-04-05T01:24:39Z")

</div>

I’m having a really hard time finding a code structure that works for me. I’m building a pretty big library of interatomic potentials. I’ve broken the code up into several files: One for each of the following sets of t…

---

## [Issue with Wildcard Import in Julia Module](https://discourse.julialang.org/t/issue-with-wildcard-import-in-julia-module/111613)

<div class="topic-metadata">

**Author:** [@Daniel\_S](https://discourse.julialang.org/u/Daniel_S)\
**Replies:** 4\
**Last updated:** [March 14, 2024, 2:23pm UTC](https://discourse.julialang.org/t/issue-with-wildcard-import-in-julia-module/111613 "2024-03-14T14:23:15Z")

</div>

I’m encountering an issue with wildcard imports (“import .ModuleName: \*”) in Julia. Specifically, when attempting to import all symbols from a module using the wildcard syntax, the symbols do not seem to be available in …

---

## [Change "current working module" from REPL](https://discourse.julialang.org/t/change-current-working-module-from-repl/53166)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 6\
**Last updated:** [February 14, 2024, 8:26pm UTC](https://discourse.julialang.org/t/change-current-working-module-from-repl/53166 "2024-02-14T20:26:42Z")

</div>

In package development, I often find myself needing to bring lots of things into scope, so I can run bits and pieces as if my package were running them. Something like julia\> using Foo # or some package I'm developing j…

---

## [Errors in creating a small, multi-file project with one module](https://discourse.julialang.org/t/errors-in-creating-a-small-multi-file-project-with-one-module/109324)

<div class="topic-metadata">

**Author:** [@Spydercrawler](https://discourse.julialang.org/u/Spydercrawler)\
**Replies:** 10\
**Last updated:** [January 29, 2024, 4:33pm UTC](https://discourse.julialang.org/t/errors-in-creating-a-small-multi-file-project-with-one-module/109324 "2024-01-29T16:33:09Z")

</div>

Hello! I am a new Julia user, using v1.10, and am struggling a bit to fully understand how to get multiple code files to work together. Specifically, I am finding that editing files can throw errors, and my using statem…

---

## [Would it make sense to roll back module definitions which error half-way?](https://discourse.julialang.org/t/would-it-make-sense-to-roll-back-module-definitions-which-error-half-way/105228)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 0\
**Last updated:** [October 20, 2023, 11:25am UTC](https://discourse.julialang.org/t/would-it-make-sense-to-roll-back-module-definitions-which-error-half-way/105228 "2023-10-20T11:25:44Z")

</div>

Consider this: julia\> module M const a = 1 error("e") const b = 2 end ERROR: e Stacktrace: \[1\] error(s::String) @ Base ./error.jl:35 \[2\] top-level scope @ REPL\[1\]:3 julia\> M.a …

---

## [How to share a duckdb database connection to many functions](https://discourse.julialang.org/t/how-to-share-a-duckdb-database-connection-to-many-functions/102921)

<div class="topic-metadata">

**Author:** [@rdavis120](https://discourse.julialang.org/u/rdavis120)\
**Replies:** 1\
**Last updated:** [August 19, 2023, 2:44pm UTC](https://discourse.julialang.org/t/how-to-share-a-duckdb-database-connection-to-many-functions/102921 "2023-08-19T14:44:49Z")

</div>

What is the best practice in Julia to share the a database connection to several functions in a module? Such as a connection from the DBInterface package. Especially, without exporting the connection variable itself, s…

---

## [Precompile error with PlotlyJS and DataFrames](https://discourse.julialang.org/t/precompile-error-with-plotlyjs-and-dataframes/102523)

<div class="topic-metadata">

**Author:** [@jekyllstein](https://discourse.julialang.org/u/jekyllstein)\
**Replies:** 0\
**Last updated:** [August 5, 2023, 8:45pm UTC](https://discourse.julialang.org/t/precompile-error-with-plotlyjs-and-dataframes/102523 "2023-08-05T20:45:22Z")

</div>

I have a package that won’t successfully precompile because one of the plot methods in PlotlyBase that is extended to DataFrames isn’t recognized during precompilation. The package has the following Project.toml name =…

---

## [Get qualified name expression from value](https://discourse.julialang.org/t/get-qualified-name-expression-from-value/102330)

<div class="topic-metadata">

**Author:** [@iago-lito](https://discourse.julialang.org/u/iago-lito)\
**Replies:** 0\
**Last updated:** [July 31, 2023, 6:50pm UTC](https://discourse.julialang.org/t/get-qualified-name-expression-from-value/102330 "2023-07-31T18:50:03Z")

</div>

Given an “item” value, say v::Union{Type,Function,Module}. I can easily get its name as a symbolic expression, like: julia\> nameof(v) :Item I can also get a string representation with its full-qualified name in the cur…

---

## [How can I structure a project in multiple modules and have code run in them?](https://discourse.julialang.org/t/how-can-i-structure-a-project-in-multiple-modules-and-have-code-run-in-them/100286)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 10\
**Last updated:** [June 15, 2023, 10:05am UTC](https://discourse.julialang.org/t/how-can-i-structure-a-project-in-multiple-modules-and-have-code-run-in-them/100286 "2023-06-15T10:05:51Z")

</div>

Hi all! Sorry this is probably noobish but I couldn’t figure it out easily from the docs/Google. I’m developing a small project for my thesis. I generated a project structure (src/, Project.toml and Manifest.toml), and …

---

## [Function whose parameter type is defined in another module](https://discourse.julialang.org/t/function-whose-parameter-type-is-defined-in-another-module/98600)

<div class="topic-metadata">

**Author:** [@zapiano](https://discourse.julialang.org/u/zapiano)\
**Replies:** 3\
**Last updated:** [May 16, 2023, 2:47am UTC](https://discourse.julialang.org/t/function-whose-parameter-type-is-defined-in-another-module/98600 "2023-05-16T02:47:16Z")

</div>

I have a custom module called Utilities, where I define the struct Utility # utilities.jl module Utilities export Utility mutable struct Utility # etc... end # ..etc end and another module called SimplexTools whe…

---

## [Export function-like objects](https://discourse.julialang.org/t/export-function-like-objects/98174)

<div class="topic-metadata">

**Author:** [@rkube](https://discourse.julialang.org/u/rkube)\
**Replies:** 4\
**Last updated:** [May 1, 2023, 8:19pm UTC](https://discourse.julialang.org/t/export-function-like-objects/98174 "2023-05-01T20:19:43Z")

</div>

Hi, in a custom module I’m defining function-like objects like this: export trf\_standardize struct trf\_standardize means stds end function (t::trf\_standardize)(x) (x .- t.means) ./ (t.stds) end How would…

---

## [Add methods to function from another module](https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083)

<div class="topic-metadata">

**Author:** [@iskyd](https://discourse.julialang.org/u/iskyd)\
**Replies:** 2\
**Last updated:** [April 30, 2023, 9:53am UTC](https://discourse.julialang.org/t/add-methods-to-function-from-another-module/98083 "2023-04-30T09:53:01Z")

</div>

Hi everyone, I have a module A that simply define a function module A """ f(config::ConnectionConfiguration) Connects to the database using the given configuration. """ function connect end end Now from modul…

---

## [Importing symbols from submodule](https://discourse.julialang.org/t/importing-symbols-from-submodule/97488)

<div class="topic-metadata">

**Author:** [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Replies:** 2\
**Last updated:** [April 14, 2023, 7:39pm UTC](https://discourse.julialang.org/t/importing-symbols-from-submodule/97488 "2023-04-14T19:39:25Z")

</div>

I’d like to import symbols from a submodule without fully qualifying the module. Like this import TestPackage.InnerMod import InnerMod: inner\_a # or import InnerMod.a But that gives me ArgumentError: Package InnerMod n…

---

## [Expected "end" error while loading a module](https://discourse.julialang.org/t/expected-end-error-while-loading-a-module/97059)

<div class="topic-metadata">

**Author:** [@Sh\_166](https://discourse.julialang.org/u/Sh_166)\
**Replies:** 2\
**Last updated:** [April 4, 2023, 1:45pm UTC](https://discourse.julialang.org/t/expected-end-error-while-loading-a-module/97059 "2023-04-04T13:45:15Z")

</div>

I am having the following problem loading a module: LoadError: syntax: "module" at C:\\Users\\shiha\\LyapunovExponentsWithForwardDiff.jl:1 expected "end", got "LyapunovExponentsResult" in expression starting at C:\\Users\\sh…

---

## [Modular local projects and \`include(...)\`](https://discourse.julialang.org/t/modular-local-projects-and-include/95781)

<div class="topic-metadata">

**Author:** [@tgross35](https://discourse.julialang.org/u/tgross35)\
**Replies:** 8\
**Last updated:** [March 10, 2023, 2:59am UTC](https://discourse.julialang.org/t/modular-local-projects-and-include/95781 "2023-03-10T02:59:00Z")

</div>

Are local files/modules ever immediately importable with using , or is include always required? For example, with a structure like this: Project.toml src/ # Source for a local library \`MyLib\` MyLib.j…

---

## [List of use´d or import'ed modules in a Julia session](https://discourse.julialang.org/t/list-of-use-d-or-imported-modules-in-a-julia-session/94584)

<div class="topic-metadata">

**Author:** [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Replies:** 9\
**Last updated:** [February 14, 2023, 2:18pm UTC](https://discourse.julialang.org/t/list-of-use-d-or-imported-modules-in-a-julia-session/94584 "2023-02-14T14:18:33Z")

</div>

Hi there I would like to understand a little bit more about the answer to the question implied on the title of this topic of mine, as per the following question from StackOverflow: List of loaded/imported packages in Ju…

[Next page](https://discourse.julialang.org/tag/modules/917.md?match_all_tags=true&page=1&tags%5B%5D=modules)
