Angular AOT and lazy loading. TypeError: System.import is not a function

Viewed 866

I am using Angular 4. After AOT and run rollup in lazy module appears this error:

Error: Uncaught (in promise):TypeError: System.import is not a function

My project works fine in JIT but in AOT I could not redirect to lazy routes. I could not understand why this error occurs.

How can I resolve this error?

Thanks.

1 Answers

It is very difficult to give a definitive answer without knowing your project setup or even a full stack trace. Lots of old angular apps use system.js (I hate it), their own webpack configs, or the CLI (my favourite).

What I would say is that I currently get this error in an old project I am bringing forward to use the CLI.

WARNING in ./node_modules/@angular/core/fesm5/core.js 15201:15-36
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
 @ ./ClientApp/vendor.ts 11:0-23

This makes me think that maybe your issue is in the angular core files (a guess with no stack trace) and so you could try updating your angular core files.

Related