Module not found: Error: Can’t resolve ‘./$$_gendir/app/app.module.ngfactory’


error in packaging to generate dist file when creating angular project:

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\web\task\src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

replace ng build — prod with ng build — env=prod, and then compile successfully.
reason: this is not based on aot, ng build – env = prod: replace with, but it’s a simple ng build. Ng build — prod: replace the improved version with aot + (previously, it was ng build — prod — aot)

Read More: