Components: Error: "Cannot read property 'forRoot' of undefined" after installing version 2.0.0-alpha.11-1

Created on 9 Dec 2016  Â·  11Comments  Â·  Source: angular/components

I uninstalled the older version @angular/[email protected] as instructed on the release notes then installed the new one and it doesn't seem to load it since on @NgModule({imports: [ ... ]})
I switched back to 2.0.0-alpha.10 and it works fine.

Which versions of Angular, Material, OS, browsers are affected?

angular: 2.2.3,
material: 2.0.0-alpha.11-1,
windows 7

Most helpful comment

Okay, I've bumped @latest to 2.0.0-alpha.11-2 which should fix this.

For anyone wondering what was wrong:
alpha.11-1 added some re-exports to index.ts files for input, tabs, menu, and select using export * (to fix a bug with AoT). We haven't had any issues with export * before, but adding these seemed to break WebPack's module loading somehow (I have no idea why). I changed the exports to use specific symbols and everything was peachy.

I'll consult with @hansl (knows more about webpack than I do) tomorrow and figure out _why_ this happened.

All 11 comments

FWIW, I updated my Material @angular/[email protected] to @angular/[email protected] in package.json, rm -rf node_modules, npm install, and ran my application without any issues...on Linux. But the same upgrade to @angular/[email protected] caused the Uncaught TypeError: Cannot read property 'forRoot' of undefined(…). Something's awry with alpha.11-1...

Does someone have a deeper stack trace?

Nevermind, I've reproduced it on a fresh angular-cli project. For some reason my existing project didn't run into this...

I've tried with alpha.10, alpha11, alpha.11-1 and all of them if you do console.log(MaterialModule) it prints undefined importing it with import { MaterialModule} from '@angular/material';
I got a repo here with a clean reproduction with angular cli https://github.com/Toxicable/materialtest
ng -v
angular-cli: 1.0.0-beta.22-1
node: 6.9.1
os: win32 x64

Uncaught TypeError: Cannot read property 'forRoot' of undefined
at app.module.ts:111
at Object. (app.module.ts:119)
at __webpack_require__ (bootstrap 98affba…:52)
at Object. (rxjs-operators.ts:46)
at __webpack_require__ (bootstrap 98affba…:52)
at Object. (src async:7)
at __webpack_require__ (bootstrap 98affba…:52)
at Object. (zone.js:1613)
at __webpack_require__ (bootstrap 98affba…:52)
at webpackJsonpCallback (bootstrap 98affba…:23)
at main.bundle.js:1

I've got a reproduction, trying to figure out _why_ it's happening; AFAICT, MaterialModule is totally there.

Have a tentative fix on the @experimental label, validating it now. Would be awesome if someone else here also confirmed.

That appears to have done it on the @experimental
yup, alpha.11-2 which is @angular/material@experimental is working for me on my projects

Okay, I've bumped @latest to 2.0.0-alpha.11-2 which should fix this.

For anyone wondering what was wrong:
alpha.11-1 added some re-exports to index.ts files for input, tabs, menu, and select using export * (to fix a bug with AoT). We haven't had any issues with export * before, but adding these seemed to break WebPack's module loading somehow (I have no idea why). I changed the exports to use specific symbols and everything was peachy.

I'll consult with @hansl (knows more about webpack than I do) tomorrow and figure out _why_ this happened.

Confirmed, @jelbourn -- my application works with 2.0.0-alpha.11-2. Thanks!

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Miiekeee picture Miiekeee  Â·  3Comments

Hiblton picture Hiblton  Â·  3Comments

alanpurple picture alanpurple  Â·  3Comments

LoganDupont picture LoganDupont  Â·  3Comments

shlomiassaf picture shlomiassaf  Â·  3Comments