gpt4 book ai didi

node.js - 为什么我得到 "TypeError: Reflect.getOwnMetadata is not a function"

转载 作者:太空宇宙 更新时间:2023-11-04 02:00:33 25 4
gpt4 key购买 nike

我正在使用 Angular2 和 Node.js 使用 ng2-File-Upload 进行文件上传但在运行我的项目时,我遇到了与 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);

最佳答案

这是我遇到完全相同问题时的情况:

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

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.

这意味着在 Typescript 编译期间定义了 Reflect.getOwnMetadata 的文件不可用。

请确保您在正确的位置引用了正确的文件,您也可能遇到这种情况。

关于node.js - 为什么我得到 "TypeError: Reflect.getOwnMetadata is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46153703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com