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

时间:2017-08-04 12:49:38

标签: prerender angular-universal platform-server

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.

1 个答案:

答案 0 :(得分:1)

你没有遗漏任何东西。不幸的是,有些库以es6格式提供,这导致您的输出包包含import / export语句,这些语句当前不受Node支持,开箱即用。 你可以找到more about this issue hereThis comment建议一些解决方法解决导入/导出问题,但会给我带来新的问题!无论如何你可以试一试。