Angular for Rails Developers Book: Deploying Angular on Rails on Heroku- Uglifier Gem
<p>I'm doing the walkthrough in this book, building a Rails API app with Angular 2 on top. <a href="https://github.com/theresaluu/tut-angular-for-rails-developers" rel="nofollow">Github</a> </p>

<p>Using two buildpacks as instructed in Angular For Rails Developer book.  </p>

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

<p>All of my updates have been checked in.  When I <code>git push heroku master</code>, I get the following error printout</p>

<pre><code>remote:        Running heroku-postbuild
remote:
remote:        &gt; author-wizard@0.0.0 heroku-postbuild /tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client
remote:        &gt; ng build
remote:
remote:        Could not start watchman; falling back to NodeWatcher for file system events.
remote:        Visit http://ember-cli.com/user-guide/#watchman for more info.
 33% building modules 19events.js:160
remote:       throw er; // Unhandled 'error' event
remote:       ^
remote:
remote: Error: This socket is closed
remote:     at Socket._writeGeneric (net.js:673:19)
remote:     at Socket._write (net.js:724:8)
remote:     at doWrite (_stream_writable.js:307:12)
remote:     at writeOrBuffer (_stream_writable.js:293:5)
remote:     at Socket.Writable.write (_stream_writable.js:220:11)
remote:     at Socket.write (net.js:651:40)
remote:     at Socket.process.stderr.write (/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/node_modules/angular-c
li/lib/cli/index.js:30:27)
remote:     at Console.warn (console.js:51:16)
remote:     at printErrorAndExit (/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/node_modules/awesome-typescript-
loader/node_modules/source-map-support/source-map-support.js:406:11)
remote:     at process.emit (/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/node_modules/awesome-typescript-loade
r/node_modules/source-map-support/source-map-support.js:419:16)
remote:     at process._fatalException (bootstrap_node.js:296:26)
remote:
remote: npm ERR! Linux 3.13.0-100-generic
remote: npm ERR! argv "/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/.heroku/node/bin/node" "/tmp/build_6cac525c
d409f823d4d8849a2cb7eba2/client/.heroku/node/bin/npm" "run" "heroku-postbuild" "--if-present"
remote: npm ERR! node v6.6.0
remote: npm ERR! npm  v3.10.3
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! author-wizard@0.0.0 heroku-postbuild: `ng build`
remote: npm ERR! Exit status 7
remote: npm ERR!
remote: npm ERR! Failed at the author-wizard@0.0.0 heroku-postbuild script 'ng build'.
remote: npm ERR! Make sure you have the latest version of node.js and npm installed.
remote: npm ERR! If you do, this is most likely a problem with the author-wizard package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR!     ng build
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR!     npm bugs author-wizard
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR!     npm owner ls author-wizard
remote: npm ERR! There is likely additional logging output above.
remote:
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR!     /tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/npm-debug.log
remote:
remote: -----&gt; Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy....
remote:
remote: !       Push rejected to evening-castle-95407.
remote:
To https://git.heroku.com/evening-castle-95407.git
 ! [remote rejected] master -&gt; master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/evening-castle-95407.git'
</code></pre>

<p>My package.json looks like this: </p>

<pre><code>{
  "name": "author-wizard",
  "version": "0.0.0",
  "engines": {
    "node": "6.6.0",
    "npm": "3.10.3"
  },
  "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",
    "@angular/compiler": "~2.0.0",
    "@angular/core": "~2.0.0",
    "@angular/forms": "~2.0.0",
    "@angular/http": "~2.0.0",
    "@angular/platform-browser": "~2.0.0",
    "@angular/platform-browser-dynamic": "~2.0.0",
    "@angular/router": "~3.0.0",
    "core-js": "^2.4.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23",
    "@types/jasmine": "^2.2.30",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.17",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  },
  "devDependencies": {
  }
}
</code></pre>

<p>The only thing I added that wasn't in the tutorial was the engine definitions, but Heroku was saying to put that in (to match my local versions) if I had problems deploying.  </p>

<blockquote>
  <p>"engines": {
      "node": "6.6.0",
      "npm": "3.10.3"
    },</p>
</blockquote>

<p>Any tips on how to move forward with deployment would be awesome.  Thanks!</p>

<p><strong>Update</strong>
changed package.json from </p>

<pre><code>"heroku-postbuild": "ng build"
</code></pre>

<p>to</p>

<pre><code>"heroku-postbuild": "ng build -prod"
</code></pre>

<p>And it deployed fine.  Still having other issues w Uglifier gem but this issue is addressed.  Thanks @jasonswett</p>