2017-09-11 33 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某處定義的文件是打字稿編譯期間不可用。

請確保您在正確的位置引用正確的文件,這可能對您也是如此。

相關問題