简体   繁体   中英

angular-cli(webpack): Uncaught Error: Cannot find module “.”

I upgraded my app from angular2 rc5 to 2.0.0. Everything working as expected.

Then I started upgrading angular-cli from 1.0.0-beta.9 to 1.0.0-beta.15 so I'm going from system to webpack. I'm having an error with @angular2-material/icon. It cannot find module '.', whatever that is.

Uncaught Error: Cannot find module "."
webpackMissingModule @ index.js: 3                  // @angular2-material/icon
(anonymous function) @ index.js: 3                  // @angular2-material/icon
(anonymous function) @ index.js: 8                  // @angular2-material/icon
__webpack_require__  @ bootstrap2fd9483…: 52
(anonymous function) @ root-app.component.ts: 66
__webpack_require__  @ bootstrap2fd9483…: 52
(anonymous function) @ src async: 7
__webpack_require__  @ bootstrap2fd9483…: 52
(anonymous function) @ zone.js: 1327
__webpack_require__  @ bootstrap2fd9483…: 52
webpackJsonpCallback @ bootstrap2fd9483…: 23
(anonymous function) @ main.bundle.js: 1

I've got Main module looks like this:

@NgModule({
  imports: [    
    SharedModule,
    [...]
  ],
  providers: [
    MdIconRegistry,
    [...]

And SharedModule like this:

@NgModule({
  imports: [
    // ANGULAR
    BrowserModule,
    FormsModule,
    RouterModule,
    ReactiveFormsModule,
    JsonpModule,

    // EXTERNAL
    MdCoreModule,
    MdIconModule,
    [...]

And my main component:

export class RootAppComponent implements OnInit {

  constructor(
    private mdIconReg: MdIconRegistry,
  ) {  }

  ngOnInit(){
    this.mdIconReg.addSvgIconSet('assets/icons/icons.svg'); 
}

Any idea what that '.' module is or how to solve it?

The problem was I wasn't loading the CoreModule. Though it was working before it failed now. Maybe I took that out somehow. Just putting CoreModule back in SharedModule worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM