15

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 Error

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

proxy.conf.json

{
  "/api": {
    "target": "http://127.0.0.1:3000",
    "secure": false
  }
}

main-polymer.ts

document.addEventListener('WebComponentsReady', () => {
  require('./main.ts');
});

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();
}

// platformBrowserDynamic().bootstrapModule(AppModule);
platformBrowserDynamic().bootstrapModule(AppModule);

how can I correct this?.

4
  • Look similar to this issue: github.com/angular/angular-cli/issues/2887 Have you tried the solution provided with the eventListener? Commented Dec 6, 2016 at 10:33
  • I want to use addEventListener to map backend. how I'm gone use that solution ?. Commented Dec 6, 2016 at 10:36
  • Problem still exists in 1.0.0-beta.24. Commented Dec 26, 2016 at 22:37
  • try with workaround in 2nd reply Commented Dec 28, 2016 at 10:13

4 Answers 4

9

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

1

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.