I am trying to deploy a production build of my Angular 7 app to Azure. I was able to easily deploy it when running ng build
but when I attempted the full ng build --prod
I receive this error below in console and the page does not load. This also happens when running the app on a localhost server as well.
Uncaught TypeError: Reflect.defineMetadata is not a function
I have searched, but I cannot find a reference to this exact error. I see most of the results are for this: Uncaught TypeError: Reflect.getMetadata is not a function
Make sure that you have reflect-metadata
installed. Also try adding this line to your polyfills.ts
file:
import 'reflect-metadata'
OR
import 'core-js/es7/reflect';
Ideally, this(the second import
statement) is already a part of the polyfills.ts
file.
That should make it work.
The import in polyfills.ts is not contained in a default Angular project anymore because Angular only needs it for dev environment.
If you need the polyfill, e.g. for modules like class-transformer
, you can add it to the polyfills.ts:
npm i core-js -S
import 'core-js/proposals/reflect-metadata';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With