Call enableProdMode() to enable the production mode.
In the Production mode, you cannot copy your files or database to the Production environment. This protects you from possibly destroying your live application by overwriting your Production files and databases. You copy databases and files up to the Production environment only until you first launch your application.
Production mode minifies your code and better represents the performance your app will have on end users' devices. Development mode includes useful warnings and gives you access to tools that make development and debugging easier.
You enable it by importing and executing the function (before calling bootstrap):
import {enableProdMode} from '@angular/core';
enableProdMode();
bootstrap(....);
But this error is indicator that something is wrong with your bindings, so you shouldn't just dismiss it, but try to figure out why it's happening.
The best way to enable the production mode for an Angular 2 application, is to use angular-cli and build the application with ng build --prod
. This will build the application with production profile. Using angular-cli has the benefit of being able to use development mode using ng serve
or ng build
while developing without altering the code all the time.
This worked for me, using the latest release of Angular 2 (2.0.0-rc.1):
main.ts
import {enableProdMode} from '@angular/core';
enableProdMode();
bootstrap(....);
Here is the function reference from their docs: https://angular.io/api/core/enableProdMode
When I built a new project using angular-cli. A file was included called environment.ts. Inside this file is a variable like so.
export const environment = {
production: true
};
Then in main.ts you have this.
import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
You could add this to a non angular-cli project, I would assume, because enableProdMode() is being imported from @angular/core.
Go to src/enviroments/enviroments.ts
and enable the production mode
export const environment = {
production: true
};
for Angular 2
To enable production mode in angular 6.X.X Just go to environment file
Like this path
Your path: project>\src\environments\environment.ts
Change production: false
from :
export const environment = {
production: false
};
To
export const environment = {
production: true
};
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