2017-09-11 31 views
1

我正在处理文件上传与Angular2和Node.js与ng2文件上传 但在运行我的项目时,我得到一个错误与反射.getOwnMetadata 这里是所示的错误:为什么我得到“TypeError:Reflect.getOwnMetadata不是函数”

enter image description here

,这里是我的systemjs.config.js

(function (global) { 
    System.config({ 
    paths: { 
     // paths serve as alias 
     'npm:': 'node_modules/' 
    }, 
    // map tells the System loader where to look for things 
    map: { 
     // our app is within the app folder 
     app: 'app', 
     // angular bundles 
     '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
     '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
     '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
     '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
     '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
     '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
     '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
     '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 
     // other libraries 
     'rxjs':      'npm:rxjs', 
     'angular-in-memory-web-api': 'npm:angular-in-memory-web-api', 
     /** Path for ng2-file-upload */ 
     'ng2-file-upload' : 'npm:ng2-file-upload' 
     /** Path for ng2-file-upload */ 
    }, 
    // packages tells the System loader how to load when no filename and/or no extension 
    packages: { 
     app: { 
     main: './transpiled-js/main.js', 
     defaultExtension: 'js' 
     }, 
     rxjs: { 
     defaultExtension: 'js' 
     }, 
     'angular-in-memory-web-api': { 
     main: './index.js', 
     defaultExtension: 'js' 
     }, 
     /** Configuration for ng2-file-upload */ 
     'ng2-file-upload' : { 
     main: './ng2-file-upload.js', 
     defaultExtension: 'js' 
     } 
     /** Configuration for ng2-file-upload */ 
    } 
    }); 
})(this); 
+0

发布与文件上传相关的代码。 –

回答

0

这是这种情况下,当我面对完全一样的问题:

我有两个同名的TypeScript文件(比如说,FileUploadService.ts)位于两个不同的位置。一个用于处理服务器逻辑(驻留在server目录中),另一个用于通过Angular服务上传文件的public目录。

The problem was that I was importing the wrong service in a location where the ng2-file-upload package was used, which in turn depends on Angular modules - which were never being imported.

这意味着,在那里Reflect.getOwnMetadata某处定义的文件是打字稿编译期间不可用。

请确保您在正确的位置引用正确的文件,这可能对您也是如此。

相关问题