core: ng2-translate not found

I’ve added ng2-translate to my system.config.js that comes with standard angular2 installation. ng2-translate is not being loaded.

var map = { 'app': 'app', // 'dist', '@angular': 'node_modules/@angular', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', 'ng2-translate': 'node_modules/ng2-translate', 'rxjs': 'node_modules/rxjs' };

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 27

Most upvoted comments

Not sure if it changes anything, but try using paths and point to the js file instead of to the bundles directory.

Maybe changing your ng2-translate entry in map to node_modules/ng2-translate/bundles/ng2-translate.umd.js might be enough. Otherwise, try using this config.

(function(global) {
  // map tells the System loader where to look for things
  var map = {
    'app':                        'app', // 'dist',
    '@angular':                   'node_modules/@angular',
    'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
    'rxjs':                       'node_modules/rxjs'
  };
  var paths = {
    'underscore':                 'node_modules/underscore/underscore.js',
    'ng2-translate':              'node_modules/ng2-translate/bundles/ng2-translate.umd.js'
  };
  // packages tells the System loader how to load when no filename and/or no extension
  var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    'ng2-translate':              { defaultExtension: 'js' }
  };
  var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'forms',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade',
  ];
  // Individual files (~300 requests):
  function packIndex(pkgName) {
    packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
  }
  // Bundled (~40 requests):
  function packUmd(pkgName) {
    packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
  }
  // Most environments should use UMD; some (Karma) need the individual index files
  var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
  // Add package entries for angular packages
  ngPackageNames.forEach(setPackageConfig);
  var config = {
    map: map,
    packages: packages,
    paths: paths
  };
  System.config(config);
})(this);

@SamVerschueren You, my friend, are a gem. Thank you very much.

@roddydairion it is pretty embarrassing to say that i simply included the wrong systemjs in my index.html as i was working on a test-project. 😃

put ‘ng2-translate’: ‘node_modules/ng2-translate/bundles’ in system.config.js in the map and ‘ng2-translate’ : { defaultExtension: ‘js’ } in packages

working example of system.config.js