ReferenceError: ngDevMode is not defined

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

Not sure

Description

A clear and concise description of the problem...

If there are compilation errors in a template (while using β€œng serve”), I am seeing the error β€œReferenceError: ngDevMode is not defined” when running in Firefox (60.6.1esr) or Edge. Chrome shows the actual compilation errors.

πŸ”¬ Minimal Reproduction

https://stackblitz.com/...

Create simple app with a component. Introduce compilation errors. Try to run app in browser.

The error (with Angular 8.1.1 is in core.js:13393

πŸ”₯ Exception or Error




ReferenceError: ngDevMode is not defined

🌍 Your Environment

Angular Version: 8.1.1 (also 8.1.0)





Anything else relevant?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:33 (23 by maintainers)

github_iconTop GitHub Comments

5reactions
hoonziscommented, Aug 7, 2019

Angular 8.2.0, I am using webpack configuration and running into the same issue when the β€˜@angular-devkit/build-optimizer/webpack-loader’ is part of the bundling process. I suppose this loadeder removes that variable.

Removing the loader from the rules fixes the issue (but results in not-optimized builds). This can be fixed by injecting the missing variables into the bundle, I have used webpack.DefinePlugin for that:

plugins.push(
      new BuildOptimizerWebpackPlugin(),
      new AngularCompilerPlugin({
        tsConfigPath: './tsconfig-aot.json',
        entryModule: './src/app/app.module#AppModule'
      }),
      new webpack.DefinePlugin({
        ngDevMode: false,
        ngI18nClosureMode: false
      })
    )

ngDevMode and ngI18nClosureMode are normally both defined in:

https://github.com/angular/angular/blob/78146c1890b472621acf33d778477db8df816043/packages/compiler-cli/src/tooling.ts

4reactions
DMezhenskyicommented, Jul 22, 2019

same issue. @angular/core 8.1.2 Is there any way to fix it?

Upd: it happens only for production build. Downgrade of all @angular/* to β€œ~8.0.0” has solved the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot redeclare block-scoped variable 'ngDevMode'
I ran into the same error, although I think it was caused by a reference to a Typescript file located in a different...
Read more >
uncaught referenceerror - ngdevmode is not defined
js. Solution 1: Using before defining - Uncaught ReferenceError: $ is not defined Case: Invoking the function or using a variable before declaring...
Read more >
ngDevMode and ngI18nClosureMode undefined error
When I ran prod build, I get `ngI18nClosureMode is not defined' and 'ngDevMode is not defined' error. Nonprod(ng build) build is fine.
Read more >
ERROR ReferenceError: Hammer is not defined (Help me)
I again here, I'm trying to install Universal Angular with mdbootstrap 6.2.2 and I have an error in the library hammer.js, I leave...
Read more >
Angular: packages/core/src/util/ng_dev_mode.ts - Fossies
24 * Finally, ngDevMode may not have been defined at all. ... you can 102 * get a `ReferenceError` like in https://github.com/angular/angular/issues/31595.
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