Rails 5 + Angular 2 app deploy to Heroku - build "success" but deployment error
<p>This is my first SO post, so please go easy on me.</p>

<p>I am trying to deploy a Rails-API app with Angular 2 embedded in the <code>client</code> folder, so that I can deploy the entire app in one go. However, when deploying with <code>git push heroku master</code>, the build "succeeds" although the app fails to deploy. </p>

<p>First I linked my Angular client app to the public folder:</p>

<pre><code>$ rm -rf public
$ ln -s client/dist public
</code></pre>

<p>Then I added the following buildpacks:</p>

<pre><code>$ heroku buildpacks:add https://github.com/jasonswett/heroku-buildpack-nodejs
$ heroku buildpacks:add heroku/ruby
</code></pre>

<p>Here is my package.json:</p>

<pre><code> {
  "name": "my_app",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor",
    "preinstall": "npm install -g node-gyp",
    "heroku-postbuild": "ng build"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "core-js": "^2.4.0",
    "rxjs": "5.0.0-beta.11",
    "ts-helpers": "^1.1.1",
    "zone.js": "0.6.12",
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.11-webpack.8",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.3",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.0",
    "awesome-typescript-loader": "2.2.1"
  },
  "devDependencies": {
  }
}
</code></pre>

<p>Following the advice from <a href="https://github.com/angular/angular-cli/issues/1997" rel="nofollow">this</a> issue post to add <code>"awesome-typescript-loader": "2.2.1"</code>to the <code>package.json</code> dependencies also did not solve the error. </p>

<p>FYI, I have been following this guide on the topic by Jason Swett: <a href="https://www.angularonrails.com/deploy-rails-application-angular-cli-webpack-front-end/" rel="nofollow">How to Deploy a Rails Application with an Angular CLI Webpack Front-End</a> </p>

<p>The relevant part of the log after <code>git push heroku master</code>:</p>

<pre><code>{...}
re34ms emitting
remote:        Hash: 8b0f868d8f0eb54b494b
remote:        Version: webpack 2.1.0-beta.21
remote:        Time: 10807ms
remote:        Asset       Size  Chunks             Chunk Names
remote:        main.bundle.js    2.51 MB    0, 2  [emitted]  main
remote:        styles.bundle.js    10.2 kB    1, 2  [emitted]  styles
remote:        inline.js    5.53 kB       2  [emitted]  inline
remote:        main.map    3.12 MB    0, 2  [emitted]  main
remote:        styles.map    14.2 kB    1, 2  [emitted]  styles
remote:        inline.map    5.59 kB       2  [emitted]  inline
remote:        index.html  472 bytes          [emitted]
remote:        chunk    {0} main.bundle.js, main.map (main) 2.46 MB {1} [initial] [rendered]
remote:        chunk    {1} styles.bundle.js, styles.map (styles) 9.96 kB {2} [initial] [rendered]
remote:        chunk    {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]
remote:
remote:        ERROR in [default] /tmp/build_26074be1021be2d930cc2ecb8ff54a9a/client/src/app/app.component.ts:5:12
remote:        Cannot find name 'require'.
remote:
remote:        ERROR in [default] /tmp/build_26074be1021be2d930cc2ecb8ff54a9a/client/src/app/app.component.ts:6:11
remote:        Cannot find name 'require'.
remote:        Child html-webpack-plugin for "index.html":
remote:        Asset     Size  Chunks       Chunk Names
remote:        index.html  2.81 kB       0
remote:        chunk    {0} index.html 339 bytes [entry] [rendered]
{...}
</code></pre>

<p>Is there any other information that may be relevant to know, in order to debug this issue?</p>