rablentain
rablentain

Reputation: 6715

Import error of node packet in Angular2

I am having some strange issues when I try to include the node_module angular2-google-maps. I get these errors:

angular2-polyfills.js:1243 Uncaught SyntaxError: Unexpected token <
    Evaluating http://127.0.0.1:3000/angular2-google-maps/core
    Error loading http://127.0.0.1:3000/public/main.ts

I can see that the path is wrong to this url: http://127.0.0.1:3000/angular2-google-maps/core, it should be http://127.0.0.1:3000/node_modules/angular2-google-maps/core.js I guess?

I import the package in my component like this:

import { ANGULAR2_GOOGLE_MAPS_DIRECTIVES } from 'angular2-google-maps/core';

Which should be right. Have I missed anything else?

Upvotes: 1

Views: 314

Answers (2)

Thierry Templier
Thierry Templier

Reputation: 202176

You could also include the bundled file angular2-google-maps.js into a script tag into your HTML entry file:

<script src="node_modules/angular2-google-maps/bundles/ angular2-google-maps.js"></script>

This file is SystemJS-compliant.

See the corresponding documentation:

Upvotes: 0

Eric Martinez
Eric Martinez

Reputation: 31777

If you're using angular2-google-maps you should check the example plnkr.

See the config.js file, it contains the following

packages: {
  'angular2-google-maps': {
    defaultExtension: 'js'
   }
}

That's the part you're missing.

Upvotes: 1

Related Questions