title: typescript cant find modules to bcrypt if .ts file deeper on folder
body: <p>The simple working code on project root folder (named here as systemname):</p>
  
  <pre><code>import * as bcrypt from 'bcrypt'; 
  
  let myvalue = "JFDSNJDSNFJSDNFSJASASNDCAUDHANDKLAMDXIALWDMQAW";
  
  bcrypt.genSalt(10, function(err, salt) {
      bcrypt.hash(myvalue, salt, function(err, hash) {
          console.log(myvalue);
          console.log(hash);
          console.log(bcrypt.compareSync(myvalue,hash));
      });
  });
  
  let salt = bcrypt.genSaltSync(10);
  let hash = bcrypt.hashSync(myvalue,salt);
  console.log(myvalue);
  console.log(hash);
  console.log(bcrypt.compareSync(myvalue,hash));
  </code></pre>
  
  <p>The following code is almost the same as above but breaks only for the class stuff and by being deep inside folder structure like <code>systemname/T/cryptUtil.ts</code>  . The code is the following:  </p>
  
  <pre><code>import * as bcrypt from "bcrypt";
  
  export class cryptUtil {
    //-------------------------------------------------
    private _rounds: number = 10;  //0xf49f6cd693d04c7ebe6928429a24f2ce;
    public get rounds(): number {
      return this._rounds;
    }
    public set rounds(rounds: number) {
      this._rounds = rounds;
    }
    //-------------------------------------------------
    public getSalt(): string {
      return bcrypt.genSaltSync(this.rounds);
    }
    //-------------------------------------------------
    public getSaltAsynchronous(
      callback: ((err: Error, salt: string) =&gt; void)
    ): void {
      bcrypt.genSalt(this.rounds, callback);
    }
    //-------------------------------------------------
    public BCryptHashGet(passw: string): string {
      return bcrypt.hashSync(passw, this.getSalt());
    }
    //-------------------------------------------------
    public BCryptHashGetAsynchronous(
      passw: string,
      callback: ((err: Error, hash: string) =&gt; void)
    ): void {
      this.getSaltAsynchronous((err: Error, salt: string) =&gt; {
        bcrypt.hash(passw, salt, callback);
      });
    }
    //-------------------------------------------------
    public BCryptHashCompare(passw: string, hash: string): boolean {
      return bcrypt.compareSync(passw, hash);
    }
    //-------------------------------------------------
    public BCryptHashCompareAsynchronous(
      passw: string,
      hash: string,
      callback: ((err: Error, isMatch: boolean) =&gt; void)
    ): void {
      bcrypt.compare(passw, hash, callback);
    }
    //-------------------------------------------------
  }
  </code></pre>
  
  <p>Another way to not receive warnings or errors is move the class to project root folder (named here as systemname) and create a file also on the root folder to test as follow:</p>
  
  <p><em>The file with class moved to root folder:</em>  </p>
  
  <pre><code>import * as bcrypt from "bcrypt";
  
  export class lxCryptUtil {
    //-------------------------------------------------
    lxGetSalt(rounds: number): string {
      return bcrypt.genSaltSync(rounds);
    }
    //-------------------------------------------------
    lxGetSaltAsynchronous(
      rounds: number,
      callback: ((err: Error, salt: string) =&gt; void)
    ): void {
      bcrypt.genSalt(rounds, callback);
    }
    //-------------------------------------------------
    lxBCryptHashGet(rounds: number, passw: string): string {
      return bcrypt.hashSync(passw, this.lxGetSalt(rounds));
    }
    //-------------------------------------------------
    lxBCryptHashGetAsynchronous(
      rounds: number,
      passw: string,
      callback: ((err: Error, hash: string) =&gt; void)
    ): void {
        this.lxGetSaltAsynchronous(rounds, (err: Error, salt: string) =&gt; {
        bcrypt.hash(passw, salt, callback);
      });
    }
    //-------------------------------------------------
    lxBCryptHashCompare(passw: string, hash: string): boolean {
      return bcrypt.compareSync(passw, hash);
    }
    //-------------------------------------------------
    lxBCryptHashCompareAsynchronous(
      passw: string,
      hash: string,
      callback: ((err: Error, isMatch: boolean) =&gt; void)
    ): void {
      bcrypt.compare(passw, hash, callback);
    }
    //-------------------------------------------------
  }
  </code></pre>
  
  <p><em>The file creatad to test the class moved to root folder:</em>  </p>
  
  <pre><code>import { lxCryptUtil } from './lxCryptUtil';
  
  export class dummy{
      processPwd(): void {
          let hash: string = "";
          let passwd: string = "FJIEJWIOEFNWONMWLEW";
          let lx = new lxCryptUtil();
          hash = lx.lxBCryptHashGet(10,passwd);
          console.log(passwd);
          console.log(hash);
          console.log(lx.lxBCryptHashCompare(passwd, hash));
      }
  }
  
  let d = new dummy();
  d.processPwd();
  </code></pre>
  
  <p>If coding the most basic possible inside a <code>.ts</code> file in project root folder there is no error with <code>@types/bcrypt</code> but if put <code>.ts</code> a bit deeper and organize inside a class then i receive errors.   </p>
  
  <p>When doing:</p>
  
  <pre><code>npm run build | grep "Can't resolve"
  </code></pre>
  
  <p>remained only the following errors:</p>
  
  <pre><code>Module not found: Error: Can't resolve 'npm' in '/systemname/node_modules/node-pre-gyp/lib/util'
  Module not found: Error: Can't resolve '../package' in '/home/myuser/node_modules/node-gyp/lib'
  Module not found: Error: Can't resolve 'aws-sdk' in '/systemname/node_modules/node-pre-gyp/lib'
  Module not found: Error: Can't resolve 'aws-sdk' in '/systemname/node_modules/node-pre-gyp/lib'
  Module not found: Error: Can't resolve 'aws-sdk' in '/systemname/node_modules/node-pre-gyp/lib'
  npm ERR! code ELIFECYCLE
  npm ERR! errno 2
  npm ERR! systemname@1.0.0 build: `webpack`
  npm ERR! Exit status 2
  npm ERR!
  npm ERR! Failed at the systemname@1.0.0 build script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/myuser/.npm/_logs/2018-01-18T01_01_01_012Z-debug.log
  </code></pre>
  
  <p>Before finding <em><b><a href="https://stackoverflow.com/q/39692275/9217154">this</a></b></em> solution there was many other errors.</p>
  
  <p>But cant keep each class in right folder to include where i want.<br>
  There is detail and current status <a href="https://github.com/kelektiv/node.bcrypt.js/issues/573" rel="nofollow noreferrer">here</a>.</p>