Skip to content

webpack2: Cannot read property 'forRoot' of undefined #2401

Closed
@robisim74

Description

@robisim74

Bug, feature request, or proposal:

After building the app with webapck, I get the following error in browser console:

Uncaught TypeError: Cannot read property 'forRoot' of undefined
    at app.bundle.js:76094
    at Object.<anonymous> (app.bundle.js:76119)
    at __webpack_require__ (app.bundle.js:48)
    at Object.<anonymous> (app.bundle.js:115880)
    at __webpack_require__ (app.bundle.js:48)
    at app.bundle.js:138
    at app.bundle.js:141

And the following is the bundle (line 76094 is the last one):

var AppModule = (function () {
    function AppModule() {
    }
    AppModule = __decorate([
        __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["b" /* NgModule */])({
            imports: [
                __WEBPACK_IMPORTED_MODULE_1__angular_platform_browser__["a" /* BrowserModule */],
                __WEBPACK_IMPORTED_MODULE_3__app_routes__["a" /* routing */],
                __WEBPACK_IMPORTED_MODULE_7__shared_shared_module__["a" /* SharedModule */],
                __WEBPACK_IMPORTED_MODULE_8__angular_material__["MaterialModule"].forRoot(),
...

What are the steps to reproduce?

import { MaterialModule } from '@angular/material';

@NgModule({
    imports: [
        BrowserModule,
        ...
        MaterialModule.forRoot()
    ],
    declarations: [
        AppComponent,
        ...
    ],
    providers: [
    ],
    bootstrap: [AppComponent]
})

export class AppModule { }

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

Angular 2.4.0
Angular Material 2.0.0-beta.1
webpack 2.2.0-rc.1
Node v6.2.2
npm 4.0.2

Is there anything else we should know?

I removed the precedent version of Material before installing the new version. No problem up to version 2.0.0-alpha.11-3

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions