When I run for debug mode with this command: npm run build
, I will have all the dist folder and I can deploy the project.
When I run for production with this command: npm run build -- --prod
, I will have this error 'Component is part of the declaration of 2 modules'.
My question is: Why this difference between the two mode ? Is this caused by the AOT option?
That's just a thing about Angular's Ahead of Time compilation. Because it eliminates code, it is a lot stricter than the debug compile and several other errors are also only reported in AOT compiles.
Generally, I do a ng build -prod
(which implies AOT) before I commit for exactly this reason.
Since you're using the npm
scripts, I would use the syntax @trichetriche suggested:
npm run build -- --aot