Webpack 无法使用AOT运行{N}应用程序,Reflect.getMetadata不是函数

Webpack 无法使用AOT运行{N}应用程序,Reflect.getMetadata不是函数,webpack,nativescript,angular2-nativescript,Webpack,Nativescript,Angular2 Nativescript,正在尝试使nativescript应用程序在启用aot的情况下运行。 使用最新版本的nativescript,它可以正常构建。启动应用程序时,会显示错误Reflect.getMetadata不是函数,并且应用程序无法工作。 使用依赖于Reflect.getMetadata的依赖项时会发生这种情况,例如: 使用aot时出现错误的演示项目: 应用程序使用JIT可以完美地运行,只有在使用--env.aot标志时才会中断。Webpack始终处于启用状态,因为这是一个角度项目(始终使用--bundle标

正在尝试使nativescript应用程序在启用aot的情况下运行。 使用最新版本的nativescript,它可以正常构建。启动应用程序时,会显示错误
Reflect.getMetadata不是函数,并且应用程序无法工作。
使用依赖于Reflect.getMetadata的依赖项时会发生这种情况,例如:

使用aot时出现错误的演示项目:

应用程序使用JIT可以完美地运行,只有在使用
--env.aot
标志时才会中断。Webpack始终处于启用状态,因为这是一个角度项目(始终使用
--bundle
标志运行)

完整堆栈跟踪:

System.err: TypeError: Reflect.getMetadata is not a function
System.err: File: "<unknown>, line: 1, column: 265
System.err: 
System.err: StackTrace: 
System.err:     Frame: function:'saveAnnotations', file:'file:///data/data/nl.persistence.stubs/files/app/vendor.js', line: 78279, column: 36
System.err:     Frame: function:'', file:'file:///data/data/nl.persistence.stubs/files/app/vendor.js', line: 78322, column: 13
System.err:     Frame: function:'module.exports../app/shared/models/user.model.ts.__decorate', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 2287, column: 110
System.err:     Frame: function:'', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 2302, column: 5
System.err:     Frame: function:'./app/shared/models/user.model.ts', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 2348, column: 2
System.err:     Frame: function:'__webpack_require__', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 752, column: 30
System.err:     Frame: function:'fn', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 122, column: 20
System.err:     Frame: function:'./app/shared/auth/auth.service.ts', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 1355, column: 76
System.err:     Frame: function:'__webpack_require__', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 752, column: 30
System.err:     Frame: function:'fn', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 122, column: 20
System.err:     Frame: function:'./app/shared/auth/auth-interceptor.service.ts', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 1280, column: 71
System.err:     Frame: function:'__webpack_require__', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 752, column: 30
System.err:     Frame: function:'fn', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 122, column: 20
System.err:     Frame: function:'./app/app.module.ngfactory.js', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 1041, column: 96
System.err:     Frame: function:'__webpack_require__', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 752, column: 30
System.err:     Frame: function:'fn', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 122, column: 20
System.err:     Frame: function:'', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 2387, column: 83
System.err:     Frame: function:'./main.ts', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 2465, column: 30
System.err:     Frame: function:'__webpack_require__', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 752, column: 30
System.err:     Frame: function:'checkDeferredModules', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 45, column: 23
System.err:     Frame: function:'', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 828, column: 18
System.err:     Frame: function:'', file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js', line: 831, column: 10
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/nl.persistence.stubs/files/app/starter.js', line: 2, column: 1
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err: 
System.err:     at com.tns.Runtime.runModule(Native Method)
System.err:     at com.tns.Runtime.runModule(Runtime.java:624)
System.err:     at com.tns.Runtime.run(Runtime.java:616)
System.err:     at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)

System.err:TypeError:Reflect.getMetadata不是函数
System.err:文件:,第1行,第265列
System.err:
System.err:StackTrace:
System.err:Frame:function:'saveAnnotations',file:'file:///data/data/nl.persistence.stubs/files/app/vendor.js,行:78279,列:36
System.err:Frame:函数:“”,文件:'file:///data/data/nl.persistence.stubs/files/app/vendor.js,行:78322,列:13
System.err:Frame:function:'module.exports../app/shared/models/user.model.ts.\uu\u decoration',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第2287行,第110列
System.err:Frame:函数:“”,文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第2302行,第5列
System.err:Frame:function:'./app/shared/models/user.model.ts',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第2348行,第2列
System.err:Frame:function:“\uuuu网页\uu require”,文件:”file:///data/data/nl.persistence.stubs/files/app/bundle.js,第752行,第30列
System.err:Frame:function:'fn',file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第122行,第20列
System.err:Frame:function:'./app/shared/auth/auth.service.ts',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第1355行,第76列
System.err:Frame:function:“\uuuu网页\uu require”,文件:”file:///data/data/nl.persistence.stubs/files/app/bundle.js,第752行,第30列
System.err:Frame:function:'fn',file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第122行,第20列
System.err:Frame:function:'./app/shared/auth/auth interceptor.service.ts',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第1280行,第71列
System.err:Frame:function:“\uuuu网页\uu require”,文件:”file:///data/data/nl.persistence.stubs/files/app/bundle.js,第752行,第30列
System.err:Frame:function:'fn',file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第122行,第20列
System.err:Frame:function:'./app/app.module.ngfactory.js',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第1041行,第96列
System.err:Frame:function:“\uuuu网页\uu require”,文件:”file:///data/data/nl.persistence.stubs/files/app/bundle.js,第752行,第30列
System.err:Frame:function:'fn',file:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第122行,第20列
System.err:Frame:函数:“”,文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第2387行,第83列
System.err:Frame:function:'./main.ts',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第2465行,第30列
System.err:Frame:function:“\uuuu网页\uu require”,文件:”file:///data/data/nl.persistence.stubs/files/app/bundle.js,第752行,第30列
System.err:Frame:function:'checkDeferredModules',文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第45行,第23列
System.err:Frame:函数:“”,文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第828行,第18列
System.err:Frame:函数:“”,文件:'file:///data/data/nl.persistence.stubs/files/app/bundle.js,第831行,第10列
System.err:Frame:function:'require',文件:“”,第1行,第266列
System.err:Frame:函数:“”,文件:'file:///data/data/nl.persistence.stubs/files/app/starter.js,第2行,第1列
System.err:Frame:function:'require',文件:“”,第1行,第266列
System.err:
System.err:at com.tns.Runtime.runModule(本机方法)
System.err:at com.tns.Runtime.runModule(Runtime.java:624)
System.err:at com.tns.Runtime.run(Runtime.java:616)
System.err:com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:at-android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
System.err:at-android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
我尝试在不同的位置导入反射元数据,包括
polyfills.ts
main.tns.ts
app.module.tns.ts
我还尝试将其包含在我的网页包/tnsconfig中,并将目标更改为es2015或es6。 这些都没有任何区别


搜索此错误会导致angular的大量常规信息,建议将
reflect metadata
的导入添加到
polyfills.ts
。这没有帮助。

在应用程序模块顶部添加
reflect metadata
包的导入语句(基本上是在访问
JsonApiDatastoreConfig
decorator之前

import "reflect-metadata";

你能分享这个可以复制问题的示例项目吗?@Manoj为演示项目添加了链接:抱歉,错误链接。演示项目在这里:这解决了问题,这么简单的修复!确保在添加此导入后删除
platforms/
文件夹,我忘了这么做,这让我相信这没有修复它。谢谢中国!