Skip to content

61 Modules ​

module.norm names the module, its version, and exported source files. The CLI discovers this description when running an entry file inside the module. package app gives the entry a top-level package name; a later lesson adds nested packages.

Entry file app/Main.norm:

norm
package app

main() {
  printLine("Hello from a module")
}

Module description app/module.norm:

norm
Module module() {
  return module(
    name: "app",
    version: 1,
    exports: ["Main"]
  )
}

Run from the repository root:

sh
norm run norm/tests/docs/projects/modules/app/Main.norm

Expected output:

text
Hello from a module

Try it: Change the module name without renaming its directory and inspect the mismatch diagnostic. Rename the module directory to match the name, update the run path, and try again.

Precise rules: Reference.

Norm 0.25