Nirav
Nirav

Reputation: 45

Angular Universal (Platform Server) : SyntaxError: Unexpected token import : for external modules

Am following this guide to enable universal rendering for my angular cli app using angular platform server. I have also updated my angular-cli and angular versions to the latest available.

All works well and I can see the pre rendering happen, except when I add an external module like ngx-facebook

When any external module is added, ts-node complaints about

SyntaxError: Unexpected token import

This happens with every external module I use like ngx-cookie or ng2-sticky which makes me think I am missing some setting in my tsconfig.

Many thanks for your help.

Upvotes: 1

Views: 763

Answers (1)

Alireza Mirian
Alireza Mirian

Reputation: 6672

You're not missing anything. Unfortunately some libraries are shipped in es6 format which cause your output bundle to include import/export statements which are not currently supported by Node, out of the box. You can find more about this issue here. This comment suggests some workaround solves import/export problem but causes new set of problems for me! You can give it a shot anyways.

Upvotes: 1

Related Questions