首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我要得到"TypeError: Reflect.getOwnMetadata不是函数“

为什么我要得到"TypeError: Reflect.getOwnMetadata不是函数“
EN

Stack Overflow用户
提问于 2017-09-11 10:39:47
回答 1查看 1.6K关注 0票数 2

我正在使用Angular2进行文件上传,Node.js使用NG2-文件上传,但是在运行我的项目时,我发现了一个与Reflect.getOwnMetadata相关的错误,这里显示的错误如下:

这是我的systemjs.config.js

代码语言:javascript
复制
(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);
EN

回答 1

Stack Overflow用户

发布于 2017-11-12 08:51:18

当我面临同样的问题时,情况就是这样:

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

问题是,我在一个使用ng2-file-upload包的位置导入了错误的服务,这反过来又取决于角度模块--这些模块从未被导入。

这意味着在类型记录编译期间,在某个地方定义Reflect.getOwnMetadata的文件不可用。

请确保您引用正确的文件在正确的位置,这也可能是你的情况。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46153703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档