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

(SystemJS) Unexpected token < #34

Closed
ujjalsuttradhar opened this issue Dec 27, 2016 · 5 comments
Closed

(SystemJS) Unexpected token < #34

ujjalsuttradhar opened this issue Dec 27, 2016 · 5 comments

Comments

@ujjalsuttradhar
Copy link

ujjalsuttradhar commented Dec 27, 2016

  1. Added this module to app from npm
  2. Added facebook sdk in index.html
<script src="https://connect.facebook.net/en_US/sdk.js"></script>
    
    <!-- Custom -->
    <script type="text/javascript" src="lib/custom.js"></script>

    <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>

component.ts

import { FacebookService } from 'ng2-facebook-sdk';


@Component({
  moduleId: module.id,
  selector: 'login',
  templateUrl: `login.component.html`,
  providers: [FacebookService]
})

export class LoginComponent {

 constructor(public fs: FacebookService) {
       
  }
}

Whenever I use FacebookService (provideres, constructor), I am getting unexpected token error. Can you help me?

@ujjalsuttradhar
Copy link
Author

FYI, Just have downloaded ng2-facebook-sdk.ts and imported FacebookService directly from this which worked properly. Seems your npm package need to be updated.

@ihadeed
Copy link
Member

ihadeed commented Dec 27, 2016

Did you modify your systemjs configuration to load the files properly?

The error you're getting is most likely caused by a 404 error. SystemJS isn't able to find the NPM package.

@ujjalsuttradhar
Copy link
Author

Which file needed to modify related to systemjs?

@ihadeed
Copy link
Member

ihadeed commented Dec 27, 2016

See #25 (comment)

@ujjalsuttradhar
Copy link
Author

Thanks. Problem is solved. For future reference, following changes solved my problem.

map: {
      // our app is within the app folder
      app: 'app',
.
.
.,
      'ng2-facebook-sdk': 'npm:ng2-facebook-sdk'
    },
   
 packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'ng2-facebook-sdk': {
        defaultExtension: 'js',
        main: './dist/index.js'
      }
    }

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

No branches or pull requests

2 participants