我的Angular-cli的角度2版本是2.0.0-rc.1。我正在尝试安装angular2-grid并按照教程中描述的确切方式进行操作,但是我发现了这个错误。
zone.js:101 GET http://localhost:4200/node_modules/angular2-grid/dist/NgGrid 404 (Not Found)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:336Zone.scheduleMacroTask @ zone.js:273(anonymous function) @ zone.js:122send @ VM6591:3fetchTextFromURL @ system.src.js:1154(anonymous function) @ system.src.js:1735ZoneAwarePromise @ zone.js:584(anonymous function) @ system.src.js:1734(anonymous function) @ system.src.js:2759(anonymous function) @ system.src.js:3333(anonymous function) @ system.src.js:3600(anonymous function) @ system.src.js:3985(anonymous function) @ system.src.js:4448(anonymous function) @ system.src.js:4700(anonymous function) @ system.src.js:406ZoneDelegate.invoke @ zone.js:323Zone.run @ zone.js:216(anonymous function) @ zone.js:571ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426
zone.js:461 Unhandled Promise rejection: Error: XHR error (404 Not Found) loading http://localhost:4200/node_modules/angular2-grid/dist/NgGrid
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:4200/vendor/zone.js/dist/zone.js:769:30)
at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:423:34)
Error loading http://localhost:4200/node_modules/angular2-grid/dist/NgGrid as "angular2-grid" from http://localhost:4200/app/banbeis.component.js ; Zone: <root> ; Task: Promise.then ; Value: Error: Error: XHR error (404 Not Found) loading http://localhost:4200/node_modules/angular2-grid/dist/NgGrid(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:4200/node_modules/angular2-grid/dist/NgGrid(…)
我跑了他们的Demo示例,它运作但是在那之后我尝试了angular-cli但是没有运气好。一个工作代码将是可观的:)
答案 0 :(得分:1)
我在BTMorton(angular2-grid的作者)的帮助下修复了它,我在angular2-grid github中打开了一个问题。我在这里发布我的解决方案。
在我的angular-cli-build.js中,我必须这样做
...
vendorNpmFiles: [
...
'angular2-grid/dist/**/*.js'
...
在system-configs.ts
中/** Map relative paths to URLs. */
const map: any = {
'angular2-grid': 'vendor/angular2-grid/dist'
};
/** User packages configuration. */
const packages: any = {
'angular2-grid': { main: 'main.js', defaultExtension: 'js' }
};
cli做了一些奇怪的捆绑,因此出现了很多错误。