title: How do I compile Typescript at Heroku postinstall?
body: <p>Instead of uploading the precompiled dist directory, I want to compile src at server side instead.</p>
  
  <p>Here are my scripts inside package.json:</p>
  
  <pre><code>"scripts": {
      "test": "echo \"No test specified\" &amp;&amp; exit 0",
      "start": "node dist/app.js",
      "postinstall": "tsc"
    }
  </code></pre>
  
  <p>Here are the dependencies:</p>
  
  <pre><code>"dependencies": {
      "@types/express": "^4.11.1",
      "@types/pg": "^7.4.4",
      "@types/socket.io": "^1.4.31",
      "body-parser": "^1.18.2",
      "express": "^4.16.2",
      "pg": "^7.4.1",
      "socket.io": "^2.0.4",
      "tslint": "^5.9.1",
      "typescript": "^2.7.2"
    }
  </code></pre>
  
  <p>Since 'npm install will add the node_modules/.bin folder to the PATH environment variable during installation', Heroku should be able to call it directly.</p>
  
  <p>But here is the error I get:</p>
  
  <pre><code>Building dependencies
         Installing node modules (package.json + package-lock)
  
         &gt; bilgi-yarismasi@1.0.0 postinstall /tmp/build_afa42c7943d4b71d2b48a016ae3b9e50
         &gt; tsc
  
         sh: 1: tsc: not found
         npm ERR! file sh
         npm ERR! code ELIFECYCLE
         npm ERR! errno ENOENT
         npm ERR! syscall spawn
         npm ERR! bilgi-yarismasi@1.0.0 postinstall: `tsc`
         npm ERR! spawn ENOENT
         npm ERR!
         npm ERR! Failed at the bilgi-yarismasi@1.0.0 postinstall 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!     /tmp/npmcache.LTxbD/_logs/2018-02-25T10_36_06_374Z-debug.log
  -----&gt; Build failed
  </code></pre>