仮想サーファーの波乗り

仮想化エンジニアの日常

プログラミング・SNS分析・仮想通貨・自動化などに関してよく書きます。

AngularアプリをHerokuにデプロイしようとしたら「Build failed」


AngularアプリケーションをHerokuにデプロイしようとしたら「Build failed」と表示され、ビルドが失敗するエラー。

▼エラー文はこちら

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: parse error: Expected another key-value pair at line 12, column 3
remote:  !     Unable to parse package.json
remote: 
remote: 
remote: -----> Build failed
remote: parse error: Expected another key-value pair at line 12, column 3
remote: parse error: Expected another key-value pair at line 12, column 3
remote: parse error: Expected another key-value pair at line 12, column 3
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 crypto-analytics.
remote: 
To https://git.heroku.com/xxxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxxxx.git'

parse errorになってるのなんでかなと思っていろいろ探っていると、package.jsonの「,」がおかしい箇所についていました。

package.json

{
  "name": "xxx",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "node server",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ng build --aot -prod",  // <- 不要な「,」が!
  },
...
}

不要な「,」を削除して再度herokuにデプロイすると...

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: 
remote: -----> Creating runtime environment
remote:        
...
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote: 
remote: -----> Compressing...
remote:        Done: 69.4M
remote: -----> Launching...
remote:        Released v7
remote:        https://xxxxx.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/xxxxx.git

成功!!

こういう不毛なエラーに時間を潰されるのは辛いな。。。


では。