title: NestJS - Injected service is undefined in the constructor
body: <p>As per <a href="https://docs.nestjs.com/components" rel="noreferrer">the documentation</a>, I inject a service in a controller's constructor, but it turns out as <code>undefined</code>.</p>
  
  <p><strong>processScraped.controller.ts</strong></p>
  
  <pre><code>import { Controller, Post, Body } from '@nestjs/common';
  import { ProcessScrapedService } from "./processScraped.service"
  
  console.log(`\nController - ProcessScrapedService = `, ProcessScrapedService) // logs : class ProcessScrapedService { ......
  
  @Controller('processScraped')
  export class ProcessScrapedController {
  
      constructor(private readonly pss: ProcessScrapedService) {
          console.log(`constructor - pss = `, pss) // logs : undefined (Should not !)
          console.log(`constructor - this.pss = `, this.pss) // logs : undefined (Should not !)
      }
  
      @Post()
      async processScraped(@Body() body) {
          console.log(`processScraped - this.pss = `,this.pss) // logs : undefined (Should not !)
          return this.pss.processScraped(body) // TypeError: Cannot read property 'processScraped' of undefined
      }
  }
  </code></pre>
  
  <p>So :</p>
  
  <ul>
  <li><p>The service exists</p></li>
  <li><p>It's imported and logged correctly as a service after import</p></li>
  <li><p>When I inject it in my controller, it's undefined.</p></li>
  </ul>
  
  <p>Maybe the problem is in the service definition?</p>
  
  <p><strong>processScraped.service.ts</strong></p>
  
  <pre><code>import { Component } from '@nestjs/common';
  
  @Component()
  export class ProcessScrapedService {
      async processScraped(body) {
          // Some logic here
          return
      }
  }
  </code></pre>
  
  <p>... Or maybe in the module?</p>
  
  <p><strong>processScraped.module.ts</strong></p>
  
  <pre><code>import { Module } from '@nestjs/common';
  
  import { ProcessScrapedController } from './processScraped.controller';
  import { ProcessScrapedService } from './processScraped.service';
  
  console.log(`\Module - nProcessScrapedService = `, ProcessScrapedService) // logs : class ProcessScrapedService { ......
  
  @Module({
      controllers: [ProcessScrapedController],
      components: [ProcessScrapedService],
  })
  export class ProcessScrapedModule { }
  </code></pre>
  
  <p>I really can't see what I'm doing wrong here??</p>
  
  <p><strong>EDIT</strong> - here are my dependencies :</p>
  
  <pre><code>"dependencies": {
      "@nestjs/common": "^4.5.9",
      "@nestjs/core": "^4.5.10",
      "@nestjs/microservices": "^4.5.8",
      "@nestjs/mongoose": "^3.0.1",
      "@nestjs/testing": "^4.5.5",
      "@nestjs/websockets": "^4.5.8",
      "@types/mongoose": "^5.0.9",
      "bluebird": "^3.5.1",
      "dotenv": "^5.0.1",
      "elasticsearch": "^14.2.2",
      "express": "^4.16.3",
      "mongoose": "^5.0.16",
      "mongoose-elasticsearch-xp": "^5.4.1",
      "reflect-metadata": "^0.1.12",
      "rxjs": "^5.5.6",
      "shortid": "^2.2.8"
    },
    "devDependencies": {
      "@types/node": "^8.0.0"
    }
  </code></pre>
  
  <p>and my tsconfig.json :</p>
  
  <pre><code>{
      "compilerOptions": {
          "target": "ES2017",
          "module": "commonjs",
          "lib": [ 
              "dom",
              "es2017"
          ],
          "outDir": "../../dist/server",
          "removeComments": true,
          "strict": true,
          "noImplicitAny": false,
          "typeRoots": [
              "node_modules/@types"
          ],
          "types": [
              "node"
          ],
          "experimentalDecorators": true
      }
  }
  </code></pre>