Page 1 of 1

Unexpected Token <

Posted: 28 Mar 2016, 01:09
by daborg69
Just discovered this toolset. Looks very nice. Trying to implement into an Angular2 project. Currently on Angular2-Beta12 and PrimeNG 0.9.

Anytime I put a:

Code: Select all

    directives: [Button], 
command in I get this error:
angular2-polyfills.js:332 Error: SyntaxError: Unexpected token <
Evaluating http://localhost:3000/node_modules/primeng/primeng
Error loading http://localhost:3000/app/main.js
IF I comment it out then the app works, but no Prime Controls.

I have the Import statement in the component

Code: Select all

import {Component, Input, Output, EventEmitter } from 'angular2/core';
import {Button, InputText} from 'primeng/primeng';
import {SalaryAdj} from './salaryAdjClass';
import {NgForm}    from 'angular2/common';
import {Employee}  from './employeeClass';
import {SalaryHistory} from './SalaryHistoryClass';
import {EmployeeService} from './employeeService';

@Component({
    selector: 'SalAdjCmp',
    templateUrl: './app/SalaryAdjustmentCmp.html',
    directives: [Button], 
    providers: [EmployeeService],

})
I have the Stylesheets and javascript in the index.html file as well as the SystemJS Code:

Code: Select all

    <!-- PrimeNG -->
<link rel="stylesheet" type="text/css" href="node_modules/primeui/themes/delta/theme.css" />
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="node_modules/primeui/primeui-ng-all.css" />
<!-- PrimeNG -->
<script src="node_modules/primeui/primeui-ng-all.js"></script>    

    <!-- 2. Configure SystemJS -->
    <script>
      System.config({
        map: { 'rxjs': 'node_modules/rxjs',
                'primeng': 'node_modules/primeng'},
        packages: {        
So am I doing something wrong or is it a bug somewhere?

Thanks in advance.

Re: Unexpected Token <

Posted: 28 Mar 2016, 11:34
by CC84
I think you are missing the defaultextension:


System.config({
defaultJSExtensions: true,
map: {
'primeng': '/app/includes'
}
});

(Ignore "/app/includes" my filelayout is a bit diffrent.)

Re: Unexpected Token <

Posted: 28 Mar 2016, 12:17
by daborg69
Cool, you put me on the right track. Had to make a slight adjustment for my system.config to get it to work as follows: Needed to add the primeng: {defaultExtension: 'js' as follows. Thanks.

Code: Select all

      System.config({
        map: { 'rxjs': 'node_modules/rxjs',
                'primeng': 'node_modules/primeng'},
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
            
                  },
          rxjs : {defaultExtension: 'js'},
          primeng : {defaultExtension: 'js'}
        }
      });

Re: Unexpected Token <

Posted: 28 Mar 2016, 16:31
by cagatay.civici
This error message is so confusing, it is thrown almost anytime something is wrong like config, invalid markup and so on. Glad to hear the issue is resolved.

Re: Unexpected Token <

Posted: 30 Mar 2016, 09:43
by CC84
The error just tells you, the browser got an Html File instead of the expected js file. Most times the browser get's the 404 error Page. In Chrome you should see an 404.