Skip to content Skip to sidebar Skip to footer

How To Add A Module To My Systemjs Config File So I Can Import It In Angular

How do add new packages I just downloaded from npm to my Angular 2 components using SystemJS and using this system.config.js file. The code bellow was generated for me by a starter

Solution 1:

Just include this file into your main HTML file (index.html):

<scriptsrc="node_modules/core-js/client/shim.min.js"></script><scriptsrc="node_modules/zone.js/dist/zone.js"></script><scriptsrc="node_modules/reflect-metadata/Reflect.js"></script><scriptsrc="node_modules/systemjs/dist/system.src.js"></script><scriptsrc="systemjs.config.js"></script> <-----

<script>System.import('app').catch(function(err){ console.error(err); });
</script>

Edit

You need to install the library using npm and configure it within the SystemJS configuration:

System.config({
  (...)
  map: {
    underscore: 'node_modules/underscore/underscore.js'
  }
});

See this question (similar but for Lodash):

Don't forget to install typings for the Underscore library.

Post a Comment for "How To Add A Module To My Systemjs Config File So I Can Import It In Angular"