模块'UploaderModule'导入的意外值'FileUploadModule' - ng2-file-upload

cro*_*umb 5 systemjs jspm angular

使用angular 2.0.1(发布)和ng2-file-upload 1.1.0(最新版本)运行此代码时出现上述错误.我正在使用带有systemjs的jspm来捆绑我的应用程序(所有这些都是最新的).

import {Component, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FileUploadModule} from 'ng2-file-upload';

@Component({
  selector: 'uploader',
  templateUrl: '/build/templates/uploader.html'
})
export class UploaderComponent {
    uploader = new FileUploader({url: '/upload'});
    hasBaseDropZoneOver = false;

    fileOverBase(event) {
        this.hasBaseDropZoneOver = event;
    }

    clearQueue() {
        this.uploader.clearQueue();
    }
}

console.log(FileUploadModule);

@NgModule({
    imports: [CommonModule, FileUploadModule],
    declarations: [UploaderComponent],
    exports: [UploaderComponent]
})
export class UploaderModule {};
Run Code Online (Sandbox Code Playgroud)

如果我检查FileUploadModule的值,它看起来非常好,就像它看起来就像我检查过的所有其他模块一样.我的应用程序中还有其他所有功能,但这一部分.这个模块的"意外"是什么?

完整错误:

错误:(SystemJS)模块'UploaderModule'(...)导入的意外值'FileUploadModule'

这是FileUploadModule导出的相对部分,对我来说很好

var FileUploadModule = (function() {
  function FileUploadModule() {}
  FileUploadModule = __decorate([core_1.NgModule({
    imports: [common_1.CommonModule],
    declarations: [file_drop_directive_1.FileDropDirective, file_select_directive_1.FileSelectDirective],
    exports: [file_drop_directive_1.FileDropDirective, file_select_directive_1.FileSelectDirective]
  }), __metadata('design:paramtypes', [])], FileUploadModule);
  return FileUploadModule;
}());
exports.FileUploadModule = FileUploadModule;
Run Code Online (Sandbox Code Playgroud)

更新: 受此反向问题的启发,我将node_module/ng2-file-upload复制到该组件所在的目录,并将我的导入更改为...

import {FileUploadModule} from './ng2-file-upload/ng2-file-upload.js'
Run Code Online (Sandbox Code Playgroud)

......它工作了!有任何想法吗?干杯.

更新2 我尝试将其导入为文件而不是模块,但将其保留到位,将导入更改为此...

import {FileUploadModule, FileUploader} from '../../../jspm_packages/npm/ng2-file-upload@1.1.0/ng2-file-upload';
Run Code Online (Sandbox Code Playgroud)

......我又回到了错误.

然后我在我的项目根目录中作为ng2-file-upload符号链接到../../../jspm_packages/npm/ng2-file-upload@1.1.0/ng2-file-upload并将我的导入更改为...

import {FileUploadModule, FileUploader} from '../../../ng2-file-upload/ng2-file-upload';
Run Code Online (Sandbox Code Playgroud)

工作正常!

所以我认为jspm/systemjs知道直接路径实际上是一个npm包,并且必须尝试以不同的方式导入它而不是直接作为文件.并且作为文件,它正确加载模块.

仅仅为了记录,因为我没有在上面指定,我使用的是纯粹的js解决方案(是的,我正在逆势而已,但不是一个打字稿的粉丝).