Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard: 30 Error: (SystemJS) Unexpected token < #71

Closed
tiagobbraga opened this issue Nov 24, 2016 · 5 comments
Closed

Dashboard: 30 Error: (SystemJS) Unexpected token < #71

tiagobbraga opened this issue Nov 24, 2016 · 5 comments

Comments

@tiagobbraga
Copy link

I have this repository with the Angular Tour of Heroes project. Include Rails to be the Angular web API and now I would like to add the angular2-token to test authentications. However, when I include the angular2-token in the project it does not compile.

The error message is:

Dashboard: 30 Error: (SystemJS) Unexpected token <

How do I proceed to configure correctly?

main.ts

"use strict";
var platform_browser_dynamic_1 = require('@angular/platform-browser-dynamic');
var app_module_1 = require('./app.module');
var platform = platform_browser_dynamic_1.platformBrowserDynamic();
platform.bootstrapModule(app_module_1.AppModule);
//# sourceMappingURL=main.js.map

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }  from '@angular/forms';
import { HttpModule }    from '@angular/http';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroesComponent } from './heroes.component';
import { DashboardComponent } from './dashboard.component';
import { HeroSearchComponent } from './hero-search.component';
import { HeroService } from './hero.service';

import './rxjs-extensions';

import { Angular2TokenService } from 'angular2-token';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule
  ],
  declarations: [
    AppComponent,
    HeroDetailComponent,
    HeroesComponent,
    DashboardComponent,
    HeroSearchComponent
  ],
  providers: [ HeroService, Angular2TokenService ],
  bootstrap: [ AppComponent ]
})

export class AppModule {

  constructor(private _tokenService: Angular2TokenService) {
    this._tokenService.init();
  }

}
@tiagobbraga
Copy link
Author

tiagobbraga commented Nov 24, 2016

In a way, I got the project rolling.

I changed the public folder systemjs.config.js

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': '/assets/'
    },
    // map tells the System loader where to look for things
    map: {
      // our application is within the app folder
      app: 'app',
      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'angular2-token.model': 'npm:angular2-token/lib/angular2-token.model.js',
      'angular2-token.service': 'npm:angular2-token/lib/angular2-token.service.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

app.module.ts from the public / app folder

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }  from '@angular/forms';
import { HttpModule }    from '@angular/http';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroesComponent } from './heroes.component';
import { DashboardComponent } from './dashboard.component';
import { HeroSearchComponent } from './hero-search.component';
import { HeroService } from './hero.service';

import './rxjs-extensions';

import { Angular2TokenService } from 'angular2-token.service';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule
  ],
  declarations: [
    AppComponent,
    HeroDetailComponent,
    HeroesComponent,
    DashboardComponent,
    HeroSearchComponent
  ],
  providers: [ HeroService, Angular2TokenService ],
  bootstrap: [ AppComponent ]
})

export class AppModule { }

app.components.ts from the public / app folder

import { Component } from '@angular/core';

import { Angular2TokenService } from 'angular2-token.service';

@Component({
  moduleId: module.id,
  selector: 'my-app',
  template: `
              <h1>{{title}}</h1>
              <nav>
                <a routerLink="/dashboard" routerLinkActive="active">Dashboard</a>
                <a routerLink="/heroes" routerLinkActive="active">Heroes</a>
              </nav>
              <router-outlet></router-outlet>
          `,
  styleUrls: ['app.component.css'],
})

export class AppComponent {
  title = 'Tour of Heroes';

  constructor(private _tokenService: Angular2TokenService) {
    this._tokenService.init();

    console.log('logged '+this._tokenService.userSignedIn());
  }
}

I just do not know if this is the best way ...

Complete Code
branch: authentication

That's the best way?

@neroniaky
Copy link
Owner

Hey @tiagobsbraga thanks for your detailed explanation.

After even angular-cli switched to webpack I did not do tests with SystemJS anymore. But seems like quite a lot of people try to make it work with the angular2 tutorial. Maybe I should add webpack as a requirement to the README until this I have the time to get this fixed.

Suggestions?

@tiagobbraga
Copy link
Author

So... I guess that we can try, do not you think?

I was not too keen on new things for the web, my focus today is more on developing mobile devices natively.

@neroniaky neroniaky added this to the 0.2.0 milestone Feb 21, 2017
@volpejoaquin
Copy link

volpejoaquin commented Jul 27, 2017

I have the same error with https://github.com/mgechev/angular-seed and angular2-token. Could you give me a solution please?.

I'm trying do the following:

File
https://github.com/mgechev/angular-seed/blob/master/tools/config/project.config.ts
Changes

// Add packages (e.g. angular2-token)
let additionalPackages: ExtendPackages[] = [
  {
    name: 'angular2-token.service',
    // Path to the package's bundle
    path: 'node_modules/angular2-token/lib/angular2-token.service.js'
  }
];
this.addPackagesBundles(additionalPackages);

File
https://github.com/mgechev/angular-seed/blob/master/src/client/app/app.component.ts
Changes

import { Angular2TokenService } from 'angular2-token.service';
console.log(Angular2TokenService);

And also have the same error:

Error: (SystemJS) Unexpected token <

@neroniaky neroniaky removed this from the 0.2.0 milestone Jul 21, 2018
@neroniaky neroniaky added 0.2.0 and removed 0.2.0 labels Jul 21, 2018
@neroniaky
Copy link
Owner

Should be fixed in the latest build. Please reopen if problem still persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants