angular-cli: Prod build fails with "Can't resolve '@angular/material/material'
Bug Report or Feature Request (mark with an x
)
- [X] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.2.1 node: 7.1.0 os: win32 x64 @angular/animations: 4.3.1 @angular/cdk: 2.0.0-beta.8 @angular/common: 4.3.1 @angular/compiler: 4.3.1 @angular/core: 4.3.1 @angular/flex-layout: 2.0.0-rc.1 @angular/forms: 4.3.1 @angular/http: 4.3.1 @angular/material: 2.0.0-beta.8 @angular/platform-browser: 4.3.1 @angular/platform-browser-dynamic: 4.3.1 @angular/router: 4.3.1 @angular/upgrade: 4.3.1 @angular/cli: 1.2.1 @angular/compiler-cli: 4.3.1
Repro steps.
Attached a cut down project that shows the issue: TestApp.zip npm install ng build --prod
The log given by the failure.
ERROR in ./app/$$_gendir/app.module.ngfactory.ts Module not found: Error: Can’t resolve ‘@angular/material/material’ in ‘C:\Code\app$$_gendir’ @ ./app/$$_gendir/app.module.ngfactory.ts 30:0-50 @ ./app/main.ts @ multi ./app/main.ts
Desired functionality.
Prod build completes without error.
Mention any other details that might be useful.
This works with angular v4.2.6 but fails with v4.3.0/v4.3.1
A non-prod build works fine.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 12
- Comments: 15 (2 by maintainers)
Heya, the Material team has identified the issue in angular/material2#6046, and are looking to fix it.
@criticalbh with
ng build --aot
, project files are compiled with Angular compiler, and generates.ngfactory.ts
files. This happens in memory with Webpack, and isn’t output to disk. It’s not possible to search workspace for any mention of it (i.e.,./app/$$_gendir/app.module.ngfactory.ts
does not exist)