这是来自您的systemjs文件。
首先,您可以映射 ng2 路由器模块,类似于您的应用程序:
var map = {
<...>
'@angular/router': 'node_modules/@angular/router',
<...>
};
接下来为它手动设置packIndex:
packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };
要修复此错误,请根据您的特定情况调整以下代码。
请注意您要使用的不同 ng2 模块和版本以及您的应用名称(如果合适,请更改):
(function(global) {
// map tells the System loader where to look for things
var map = {
'YourApp': 'YourApp', // 'dist',
'@angular': 'node_modules/@angular',
'@angular/router': 'node_modules/@angular/router',
'rxjs': 'node_modules/rxjs'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'YourApp': { main: 'app.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' }
};
var ngPackageNames = [
'common',
'forms',
'compiler',
'core',
'http',
'platform-browser',
'platform-browser-dynamic',
'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' };
}
packages['@angular/router'] = { main: 'index.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
};
System.config(config);
})(this);