我在使用 IIS 的 ASP.NET Core 解决方案上使用 VS2015 RC3、Angular2 2.0.0。
每当我尝试添加新的 UI 模块(例如下拉菜单或输入)时,都会收到 SystemJS 错误,但奇怪的是我的按钮可以正常工作...
master.module.ts:
import { ButtonsModule } from '@progress/kendo-angular-buttons';
import { DropDownsModule } from '@progress/kendo-angular-dropdowns';
import { InputsModule } from '@progress/kendo-angular-inputs';
@NgModule({
imports: [
CommonModule,
MasterRouting,
ButtonsModule, // => Works fine and button is showing as expected
InputsModule, // Error : Unexpected Token
DropDownsModule // Error : Unexpected Token
],
[...]
我收到这些错误(取决于我尝试在“导入”数组中添加的模块:
InputsModule 错误:指向我的master.modules.ts中的导入行
zone.js:192 错误:(SystemJS) 意外令牌 < SyntaxError: Unexpected token < 在 Object.eval ( http://localhost:39351/app/master/master.module.js:35:30 )
DropdownsModule 错误:
zone.js:192 错误:(SystemJS) 意外令牌 < SyntaxError: Unexpected token < 在 Object.eval ( http://localhost:39351/node_modules/@progress/kendo-angular-dropdowns/dist/npm/js/combobox.组件.js:630:19 )
这个向我展示了剑道库中的导入:
module.exports = require("@telerik/kendo-dropdowns-common/dist/npm/js/bundle");
我确保我的 wwwroot 中有...
编辑:正如您在错误列表中看到的那样,它正在尝试使用不正确的路径评估 @telerik 包,所以我猜错误来自那里,但是他们为什么不为 Telerik 包设置 SystemJS 配置文件?我在那里错过了什么吗?
我完全迷路了,所以非常感谢任何帮助......
以下是其他一些文件,以防万一:
tsconfig.json:
{
"compilerOptions": {
"outDir": "./wwwroot/app/",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"inlineSourceMap": true,
"inlineSources": true
},
"exclude": [
"./node_modules/**",
"./wwwroot/**",
"./typings/**"
]
}
systemjs.config.js:
(function (global) {
// map tells the System loader where to look for things
var map = {
// Our components
'app': 'app', // 'dist',
// Angular2 + rxjs
'@angular': 'node_modules/@angular',
'rxjs': 'node_modules/rxjs',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
// Kendo Angular2
'@progress/kendo-angular-buttons': 'node_modules/@progress/kendo-angular-buttons',
'@progress/kendo-angular-dropdowns': 'node_modules/@progress/kendo-angular-dropdowns',
'@progress/kendo-angular-inputs': 'node_modules/@progress/kendo-angular-inputs',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
// Our components
'app': { defaultExtension: 'js'},
// Angular2 + rxjs
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'@progress/kendo-angular-buttons': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'@progress/kendo-angular-dropdowns': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'@progress/kendo-angular-inputs': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
};
/**** node_modules basic config ! Do not touch ****/
// name of packages to assimilate (angular 2 only here)
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
};
System.config(config);
/**** node_modules basic config ! Do not touch ****/
})(this);