How to check if Angular application running in Production or Development mode

前端 未结 6 613
挽巷
挽巷 2020-12-07 17:27

This seems an easy one, but I couldn\'t find any solution.

So, how do I check if my app is running in production mode or dev mode?

6条回答
  •  Happy的楠姐
    2020-12-07 17:48

    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
    import { enableProdMode } from '@angular/core';
    import { AppModule } from './app.module'
    
    
    platformBrowserDynamic().bootstrapModule(AppModule);
    enableProdMode();
    

    This was my code, so I got the same error. I just interchanged line 3 and 4. Then the issue is fixed. So before bootstrapping module we should enable --prod mode.

    The correct one can be put in this way,

    enableProdMode()
    platformBrowserDynamic().bootstrapModule(AppModule);
    

提交回复
热议问题