Codes / Error Code 011
Codes / Error Code 011
Error Code 011
Overview
This error occurs when the compiler cannot find a module specified in an import statement. It typically results from incorrect module names, missing files, or improper project configuration.
Details
-
Common Causes:
- Specifying a module that doesn’t exist in the source directories.
- Typographical errors in the module name.
- Missing paths or misconfigured imports in the project setup.
-
Example:
import nonexistentmodule; // Error: module `nonexistentmodule` not found
void main() {
writeln("Hello, World!");
}
- Solution:
-
Ensure the module exists in the project directory structure:
// Correct module declaration in a file named mymodule.d module mymodule; void myFunction() { writeln("This is my module!"); }- Import it properly:
import mymodule; void main() { myFunction(); }
- Import it properly:
-
Add the correct source paths to your project configuration:
dmd -I./src myprogram.d -
Double-check for typographical errors in the
importstatement.
-