question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enableProdMode console message is too mysterious

See original GitHub issue

I got this message in the console:

Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.

Curious, I behaved literally and typed this into the console:

enableProdMode();

At which point I was greeted with this error:

VM1256:2 Uncaught ReferenceError: enableProdMode is not defined(…)(anonymous function) @ VM1256:2
InjectedScript._evaluateOn @ VM1126:875
InjectedScript._evaluateAndWrap @ VM1126:808
InjectedScript.evaluate @ VM1126:664

This console message should link to docs explaining what enableProdMode is and an example of how exactly to enable it. For example, something like this would have been much clearer (not sure if this is how you do it exactly):

import {enableProdMode} from "angular2/core";

enableProdMode();

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:54
  • Comments:26 (4 by maintainers)

github_iconTop GitHub Comments

61reactions
VishalMadhvanicommented, Jan 25, 2016

It also works when done on the boot.ts file. Mine now looks like this:

import {bootstrap}    from 'angular2/platform/browser'
import {AppComponent} from './app.component'
import {enableProdMode} from 'angular2/core';

enableProdMode();
bootstrap(AppComponent);

But now instead of Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode. i’m getting Angular 2 is running in the production mode. Call enableDevMode() to enable the development mode.

Surely in a production mode there shouldn’t be any messages, specifically given that one has to write code to enable production mode.

17reactions
powercoder23commented, Jan 19, 2016

Guys just write this code on the bootstraped Component and make sure it is not inside any class or constructor just one below the other, it worked for me.!

//.. other imports
import {enableProdMode} from 'angular2/core';
enableProdMode();

@Component({
//...my component code goes here

hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling production mode in angular 2 using ... - Stack Overflow
Call enableProdMode() to enable the production mode.". why it is showing in console don't know . Please tell me the steps to resolve...
Read more >
enableProdMode - Angular
enableProdMode link​​ Disable Angular's development mode, which turns off assertions and other checks within the framework.
Read more >
Workflow of Angular - Medium
So, enableProdMode() is not get executed as the condition failed. To verify that, I have given a console message in the else block...
Read more >
Site Cannot be installed: No Matching Service Worker expected
Let me show one of the generic issue which I faced. This message is self explanatory as the chrome couldn't detect service worker,...
Read more >
Applying Universal Schematics - The newline Guide to ...
After applying the schematics, you should see the summary output of what has been ... Both solutions are watching your project for changes,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found