N
N
No Name2016-12-07 16:34:36
JavaScript
No Name, 2016-12-07 16:34:36

How to fix 'Unexpected token import' error?

I am writing an application in Angular 2 + Typescript. I build the project using Webpack.
Here are the source code for the client application:
https://github.com/alex-chaliy/contacts-ng2/tree/m... Webpack builds fine and doesn't throw any errors, but I get an 'Unexpected token import'
error in the browser console when I try to
connect angular components via import.
070d33e1a2be4506ba5f0690b738393b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2016-12-07
@alienworkshop

1) tsconfig.json
2) package.json

"dependencies": {
    "angular2": "^2.0.0-beta.21",
    "rxjs": "^5.0.0-rc.4",
   +"reflect-metadata": "0.1.2",
   +"zone.js": "^0.6.11"
}

3) entry file app.ts
Add on top
import 'reflect-metadata';
import 'zone.js';

And probably you can use not a beta version, but something newer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question