components icon indicating copy to clipboard operation
components copied to clipboard

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

Open aveniri opened this issue 9 years ago • 11 comments

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

aveniri avatar Dec 09 '16 00:12 aveniri

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

JanStureNielsen avatar Dec 09 '16 00:12 JanStureNielsen

Does someone have a deeper stack trace?

jelbourn avatar Dec 09 '16 01:12 jelbourn

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

jelbourn avatar Dec 09 '16 01:12 jelbourn

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

Toxicable avatar Dec 09 '16 01:12 Toxicable

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

blyndcide avatar Dec 09 '16 01:12 blyndcide

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

jelbourn avatar Dec 09 '16 01:12 jelbourn

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

jelbourn avatar Dec 09 '16 01:12 jelbourn

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

Toxicable avatar Dec 09 '16 01:12 Toxicable

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.

jelbourn avatar Dec 09 '16 02:12 jelbourn

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

JanStureNielsen avatar Dec 09 '16 02:12 JanStureNielsen

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.