Hello!
I get this error and can not fix it. I tried many things to handle it. But I failed.
Here is my set-up. I am using CocosCreator 1.6.2 and Typescript.
I want to use RobotlegsJS so I install it via npm (https://github.com/RobotlegsJS/RobotlegsJS) and applied recomended compiler options. npm install @robotlegsjs/core reflect-metadata --save
And in my Main class I add this
import {Context} from "@robotlegsjs/core"; onLoad() { let context = new Context(); }
Thats all I did. When I run the project it throws the error:
Uncaught TypeError: Reflect.hasOwnMetadata is not a function at injectable.js:7 at __decorate (RobotlegsInjector.js:6) at RobotlegsInjector.js:15 at __define (RobotlegsInjector.js:15) at Object.func (RobotlegsInjector.js:15) at Object.cc.require (modular.js:64) at __require (Context.js:1) at __define (Context.js:24) at Object.func (Context.js:49) at Object.cc.require (modular.js:64)
I think Reflect.js file was loaded too late. It should load in the beginning.
I tried to add jsList to project.json like that:
HI jrosich,
Thanks for the reply.
Other node modules works fine. Only that Reflect module is not working properly. Yesterday I spend quite a time on it. Reflect module should have been loaded and initialized before a module needs it. So I put this on third line in the robotlegs/index.js file.
var reflect_1 = require("./../../../reflect-metadata/Reflect");
That solves my issue. I am not happy for this solution but it works for now. Hope in new version of the creator we will not have this.
Hey @jare, yes you are right. I created a clean project and removed all “@”. Then I added this line at Main.ts top:
import "reflect-metadata";
it works. Thank you.
But now I can not use npm. Because robotlegsjs named itself as @robotlegs/core.
I can not use package control. I will search to use modules with custom names. It is not a big deal but do you have any suggestion?
@slackmoehrle it looks like there is a parse problem. I look forward to hearing from you soon.