Angular cli after update npm start give error

前端 未结 4 1668
执笔经年
执笔经年 2021-02-13 05:08

I create application using angular cli and use backend proxy to handle backend and using polymer(vaadin) it work correctly until I update to angular cli 1.0.0-beta.22 it give Er

相关标签:
4条回答
  • 2021-02-13 05:27

    This is caused by Angular CLI latest update. In the latest update, webpack searches for boostrap Module in main.ts top level. In main-polymer.ts, main.ts is wrapped by addEventListener so webpack can't find the bootstrap module that's why it reports an error.

    Further reference github.com/angular/angular-cli/issues/2887

    0 讨论(0)
  • Using github I have found a workaround that is work for me I remove the main-polymer.ts file and edited the main ts file as below.

    main.ts

    import './polyfills.ts';
    
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    import { enableProdMode } from '@angular/core';
    import { environment } from './environments/environment';
    import { AppModule } from './app/';
    
    if (environment.production) {
      enableProdMode();
    }
    
    var webComponentsFlag = false;
    document.addEventListener('WebComponentsReady',() =>{
      if (!webComponentsFlag)
        platformBrowserDynamic().bootstrapModule(AppModule);
      webComponentsFlag = true;
    });
    if (webComponentsFlag)
     platformBrowserDynamic().bootstrapModule(AppModule);
    

    and it worked for me. but can't build using ng build to overcome this problem refer the

    github issue

    0 讨论(0)
  • 2021-02-13 05:28

    I had the same problem, what I did is go back to 1.0.0-beta.21 and it work again :)

    0 讨论(0)
  • 2021-02-13 05:47

    I have noticed that it sometimes happens when you have an invalid import statement! if for some reason you have deleted a component and you left the import there, then it will give you:

    "Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options."

    0 讨论(0)
提交回复
热议问题