Reputation: 3979
I use this import statement in one of component file:
import {BehaviorSubject} from 'rxjs';
@Injectable()
export class UserService {
private currentUser = new BehaviorSubject<User>(null);
}
When the browser loads the app, it throws the exception below:
SyntaxError: Unexpected token <
Evaluating http://localhost:3000/rxjs
Error loading http://localhost:3000/app/components/app.js
at eval (native)
at SystemJSLoader.__exec (http://localhost:3000/vendors.js:3320:16)
I don't know why it didn't work. Cause Angular2 worked already. Could any one please help me this case?
Upvotes: 3
Views: 1594
Reputation: 202346
I think that it's not somethying related to concatenation with Gulp but with the module you use.
You should use one of the following:
import {BehaviorSubject} from 'rxjs/Rx';
or
import {BehaviorSubject} from 'rxjs/subject/BehaviorSubject';
In fact, RxJS doesn't register a rxjs
module directly but sub modules (something like rxjs/something
). So SystemJS can't find a previously registered module so it tries to load from the address http://localhost:3000/rxjs
but a 404 error is returned...
Upvotes: 6