问题
I have a project that built fine with ng build --prod until I upgraded the version of TypeScript from 2.72 to 2.92 in my package.json.
After upgrading, I now get the following error:
ERROR in Cannot read property 'Symbol(Symbol.iterator)' of undefined
However, the project builds fine using ng build and runs fine using ng serve so I have no idea where this problem is occurring and the error doesn't tell me where the problem is in my project.
回答1:
I found the issue. Using resolveJsonModule seems to be the issue as pointed out via this issue on Github: https://github.com/angular/angular/issues/25456
Exact same error. Really surprised that this hasn't been fixed properly.
Problem was I had no clue what the problem was as the error message was so vague. Commenting out my json import in my app.module made the build work as intended.
来源:https://stackoverflow.com/questions/58931483/error-building-with-ng-build-prod-fine-without-prod-flag-and-ng-serve