Skip to main content

L1202 - Redefining module

Error

    -module(my_module).
-module(my_module).
%% ^^^^^^^^^^^^^^^^^^^ error: redefining module

Explanation

This error occurs when you attempt to define the module name more than once using the -module directive.

Each Erlang source file should contain exactly one -module directive, and it should appear at the beginning of the file.

To fix this error:

  1. Remove the duplicate -module directive
  2. Ensure only one -module directive exists in your file
%% Correct approach - single module definition
-module(my_module).