Unexpected Token <

UI Components for Angular
Post Reply
daborg69
Posts: 3
Joined: 28 Mar 2016, 00:32

28 Mar 2016, 01:09

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.

CC84
Posts: 69
Joined: 11 Mar 2016, 09:32

28 Mar 2016, 11:34

I think you are missing the defaultextension:


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

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

daborg69
Posts: 3
Joined: 28 Mar 2016, 00:32

28 Mar 2016, 12:17

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'}
        }
      });

cagatay.civici
Prime
Posts: 18478
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

28 Mar 2016, 16:31

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.

CC84
Posts: 69
Joined: 11 Mar 2016, 09:32

30 Mar 2016, 09:43

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.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests