Solvedangular AOT: Cannot determine the module for class <...>Component

I'm submitting a...

[x] Regression (a behavior that used to work and stopped working in a new release)

Current behavior

Compilation in prod / AOT mode fails with the given error message for EVERY component in my project, even the bootstrapped ApplicationComponent.
All mentioned components are declared in their corresponding modules.
JIT works without any errors / warnings / problems, AOT used to work in earlier versions.

ERROR in Error: Cannot determine the module for class LayoutComponent in C:/path/to/src/code/layout/components/layout/layout.component.ts! Add LayoutComponent to the NgModule to fix it.
Cannot determine the module for class ThemeComponent in C:/path/to/src/code/theme/components/theme/theme.component.ts! Add ThemeComponent to the NgModule to fix it.
Cannot determine the module for class ApplicationComponent in C:/path/to/src/code/application/components/application/application.component.ts! Add ApplicationComponent to the NgModule to fix it.
Cannot determine the module for class ErrorPageComponent in C:/path/to/src/code/application/components/error-page/error-page.component.ts! Add ErrorPageComponent to the NgModule to fix it.
Cannot determine the module for class TranslationDirective in C:/path/to/src/code/application/components/translations/translation.directive.ts! Add TranslationDirective to the NgModule to fix it.
Cannot determine the module for class TranslationsComponent in C:/path/to/src/code/application/components/translations/translations.component.ts! Add TranslationsComponent to the NgModule to fix it.
Cannot determine the module for class DashboardComponent in C:/path/to/src/code/m-m/components/dashboard/dashboard.component.ts! Add DashboardComponent to the NgModule to fix it.
    at syntaxError (C:\path\to\node_modules\@angular\compiler\bundles\compiler.umd.js:503:34)
    at validateAnalyzedModules (C:\path\to\node_modules\@angular\compiler\bundles\compiler.umd.js:29435:15)
    at analyzeAndValidateNgModules (C:\path\to\node_modules\@angular\compiler\bundles\compiler.umd.js:29424:12)
    at AotCompiler.analyzeModulesAsync (C:\path\to\node_modules\@angular\compiler\bundles\compiler.umd.js:28763:46)
    at CodeGenerator.codegen (C:\path\to\node_modules\@angular\compiler-cli\src\codegen.js:32:14)
    at Function.NgTools_InternalApi_NG_2.codeGen (C:\path\to\node_modules\@angular\compiler-cli\src\ngtools_api.js:70:30)
    at _donePromise.Promise.resolve.then (C:\path\to\node_modules\@ngtools\webpack\src\plugin.js:426:44)
    at 
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:667:11)
    at startup (bootstrap_node.js:201:16)
    at bootstrap_node.js:626:3

Expected behavior

Compile the app.

Environment

angular: 5.0.0-rc.0
angular-cli: 1.5.0-beta.3
ngtools/webpack: 1.8.0-beta.2
Node: 8.5.0
NPM: 5.3.0
Webpack: 3.6.0
Windows 10
27 Answers

✔️Accepted Answer

Make sure the import path case matches with the actual file path case. I got the same error, for my MyUserComponent class shown below. Note the case of the import path (all the letters are in lower case).

import { MyUserComponent } from './user/myusercomponent.component';

The actual file name of MyUserComponent was

myUserComponent.component.ts (note that U and C are in upper case)

Once I changed the import statement to the following
import { MyUserComponent } from './user/myUserComponent.component';
the error disappeared.

More Issues: