title: TypeError: Reflect.hasOwnMetadata is not a function
body: <p>I am trying to use inversify with typescript and node.js.  I am currently using node.js version 6.9.1, typescript version 2.6.2, and ECMAScript 6.  When I try to run the node.js application, I keep receiving the following error, "TypeError: Reflect.hasOwnMetadata is not a function".</p>
  
  <p>Following documentation I found online, by adding import "reflect-matadata"  at the top of the inversify.config.js file, it seemed to work for awhile,  but now the problem is back again.  </p>
  
  <p>In my inversify.config.ts file, I have the following code that gets called from my app.ts file:</p>
  
  <pre><code>export let initialize = async (): Promise&lt;Container&gt; =&gt; {
          var container = new Container();
  
          try {
                  if (!Reflect.hasOwnMetadata("inversify:paramtypes", ClassToAddInjectableTo)) {
                          decorate(injectable(), ClassToAddInjectableTo);
                  }
  
                  ….
  
              container.bind&lt;interfaces.Controller&gt;(TYPE.Controller).to(MyController1).whenTargetNamed('MyController1');
              container.bind&lt;interfaces.Controller&gt;(TYPE.Controller).to(MyController2).whenTargetNamed('MyController2');
          } catch (ex) {
              throw ex;
          }
  }
  </code></pre>
  
  <p>This code exists in app.ts and it calls the code in the inversify.config.ts file:</p>
  
  <pre><code>setup = async () =&gt; {
      try {
          let container: Container = await initialize();
          …..
  
      } catch (err){
          throw err;
      }
  }
  </code></pre>
  
  <p>The problem seems to be on the following line in node_modules/inversify/lib/annotation/decorator_utils.js:22: </p>
  
  <pre><code>if (Reflect.hasOwnMetadata(metadataKey, annotationTarget) === true) {
  </code></pre>
  
  <p>In the generated inversify.config.js file, the following code seems to be above the import "reflect-metadata":</p>
  
  <pre><code>var __awaiter = (this &amp;&amp; this.__awaiter) || function (thisArg, _arguments, P, generator) {
      return new (P || (P = Promise))(function (resolve, reject) {
          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
          step((generator = generator.apply(thisArg, _arguments || [])).next());
      });
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  require("reflect-metadata");
  </code></pre>
  
  <p>I noticed that the help I found online only indicated that I needed to add import "reflect-metadata".</p>
  
  <p>Also, here is my tsconfig.json file:</p>
  
  <pre><code>{
    "compilerOptions": {
      "module": "commonjs",
      "target": "ES6",
      "moduleResolution": "node",
      "experimentalDecorators": true,
      "emitDecoratorMetadata": true,
      "types": ["reflect-metadata"],
      "lib": ["ES6"],
      "sourceMap": true,
      "inlineSources": true,
      "pretty": true,
      "outDir": "dist",
      "rootDir": "src",
      "noLib": false,
      "declaration": true
    },
    "include": [
      "src/**/*"
    ],
    "exclude": [
      "node_modules"
    ]
  }
  </code></pre>
  
  <p>Could someone please review and let me know what I could be missing?</p>
  
  <p>Update: For the issue above, I added the import "reflect-metadata" to the file inversify.config.ts file.  However, I commented this import statement and added the import "reflect-metadata" to the app.ts file and now I am getting a different error: </p>
  
  <pre><code>throw new Error(ERRORS_MSGS.DUPLICATED_INJECTABLE_DECORATOR);
              ^
  
  Error: Cannot apply @injectable decorator multiple times.
  </code></pre>
  
  <p>Now I found a post on the internet that seemed to describe indicate the adding import "reflect-metadata" adds a Reflect global variable.  Also, I don't know if this helps but I removed the @injectable decorator from the controllers.</p>