I am trying to import a node module into Angular 2 but with no avail.
How can this be achieved?
I am trying to import the following module into Angular 2: https://www.npmjs.com/package/countryjs
Do i need to use system.js to register it into the current app:
<!-- 2. Configure SystemJS -->
    <script>
      System.config({
        packages: {
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          map: {
              'countryjs': 'node_modules/countryjs/lib/countryjs'
          },
          meta: {
              // sets meta for modules within the package
              'vendor/*': {
                  'format': 'global'
              }
          }
        }
      });
      System.import('app/boot')
            .then(null, console.error.bind(console));
    </script>
Then in the ts file, I use:
import {} from "countryjs"
When i use this (below) it gives me an error
import {Country} from "countryjs"
Am I missing something?
First of all sorry for not posting for so long.
I finally found a solution for this. Please find the altered system.js script:
System.config({
                defaultJSExtensions: true,
                packages: {
                    'app': { format: 'register', "defaultExtension": 'js' }
                },
                map: {
                    'angular2': 'node_modules/angular2',
                    'primeng': 'node_modules/primeng',
                    'rxjs': 'node_modules/rxjs',
                    'ng2-uploader': 'node_modules/ng2-uploader/ng2-uploader',
                    'countryjs': 'node_modules/countryjs'
                }
            });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With