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.

"Class constructor NgModuleInjector cannot be invoked without 'new'" when AOT with fesm15 files

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior When building an app with fesm15 and AOT I get the following exception in the browser during bootstrap:

app.module.ngfactory.ts:55 Uncaught TypeError: Class constructor NgModuleInjector cannot be invoked without 'new'
    at new AppModuleInjector (app.module.ngfactory.ts:55)
    at NgModuleFactory.create (ng_module_factory.ts:70)
    at ngZone.run (application_ref.ts:301)
    at ZoneDelegate.webpackJsonp.ZSR1.ZoneDelegate.invoke (zone.js:334)
    at Object.onInvoke (ng_zone.ts:256)
    at ZoneDelegate.webpackJsonp.ZSR1.ZoneDelegate.invoke (zone.js:333)
    at Zone.webpackJsonp.ZSR1.Zone.run (zone.js:126)
    at NgZone.run (ng_zone.ts:142)
    at PlatformRef_._bootstrapModuleFactoryWithZone (application_ref.ts:299)
    at PlatformRef_.bootstrapModuleFactory (application_ref.ts:332)
    at Object.x35b (main.ts:11)
    at __webpack_require__ (bootstrap 21cb324…:52)
    at Object.2 (app.component.ngfactory.ts:48)
    at __webpack_require__ (bootstrap 21cb324…:52)
    at webpackJsonpCallback (bootstrap 21cb324…:23)

Expected behavior no error 😃

Minimal reproduction of the problem with instructions

  1. ng new --ng4 test-app
  2. edit vi node_modules/\@angular/cli//models/webpack-configs/common.js and mainFields: ["es2015", "module", "main"] to resolve: { ... } block
  3. disable Uglify in node_modules/\@angular/cli//models/webpack-configs/common.js
  4. ng serve --prod --sm
  5. open http://localhost:4200 and check error in console
  • Angular version: 4.0.0-rc.5

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IgorMinarcommented, Mar 22, 2017

Confirmed. I modified the tsconfig in my app to "target": "es2015" and now it works

0reactions
angular-automatic-lock-bot[bot]commented, Sep 11, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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