angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Heroku deploying failed

Open chiholiu10 opened this issue 9 years ago • 11 comments

$ git push heroku master Counting objects: 41149, done. Delta compression using up to 4 threads. Compressing objects: 100% (29819/29819), done. Writing objects: 100% (41149/41149), 50.88 MiB | 590.00 KiB/s, done. Total 41149 (delta 15613), reused 32978 (delta 9399) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NPM_CONFIG_PRODUCTION=true remote: NODE_VERBOSE=false remote: NODE_ENV=production remote: NODE_MODULES_CACHE=false remote: remote: -----> Installing binaries remote: engines.node (package.json): 6.9.1 remote: engines.npm (package.json): 5.3.0 remote: remote: Resolving node version 6.9.1... remote: Downloading and installing node 6.9.1... remote: Bootstrapping npm 5.3.0 (replacing 3.10.8)... remote: npm 5.3.0 installed remote: remote: -----> Restoring cache remote: Skipping cache restore (disabled) remote: remote: -----> Building dependencies remote: Installing node modules (package.json + package-lock) remote: remote: > [email protected] install /tmp/build_b4d1c5f120c3a88c9eb3fce52d93416e/node_modules/node-sass remote: > node scripts/install.js remote: remote: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-48_binding.node remote: Download complete remote: Binary saved to /tmp/build_b4d1c5f120c3a88c9eb3fce52d93416e/node_modules/node-sass/vendor/linux-x64-48/binding.node remote: Caching binary to /app/.npm/node-sass/4.5.3/linux-x64-48_binding.node remote: remote: > [email protected] postinstall /tmp/build_b4d1c5f120c3a88c9eb3fce52d93416e/node_modules/node-sass remote: > node scripts/build.js remote: remote: Binary found at /tmp/build_b4d1c5f120c3a88c9eb3fce52d93416e/node_modules/node-sass/vendor/linux-x64-48/binding.node remote: Testing binary remote: Binary is fine remote: remote: > @angular/[email protected] postinstall /tmp/build_b4d1c5f120c3a88c9eb3fce52d93416e remote: > ng build --aot -prod remote: remote: sh: 1: ng: not found remote: npm ERR! file sh remote: npm ERR! code ELIFECYCLE remote: npm ERR! errno ENOENT remote: npm ERR! syscall spawn remote: npm ERR! @angular/[email protected] postinstall: ng build --aot -prod remote: npm ERR! spawn ENOENT remote: npm ERR! remote: npm ERR! Failed at the @angular/[email protected] postinstall script. remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. remote: remote: npm ERR! A complete log of this run can be found in: remote: npm ERR! /app/.npm/_logs/2017-08-30T14_02_27_087Z-debug.log remote: remote: -----> 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 desolate-springs-30268. remote: To https://git.heroku.com/desolate-springs-30268.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/desolate-springs-30268.git'

Package.sjon

{ "name": "my-wonderful-app", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "node server.js", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "prestall": "", "postinstall": "ng build --aot --target=production" }, "private": true, "dependencies": { "@angular/cli": "1.2.3", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.25", "@types/jquery": "^2.0.43", "angularfire2": "^4.0.0-rc.0", "bootstrap": "^3.3.6", "core-js": "^2.4.1", "express": "^4.15.4", "firebase": "^3.9.0", "rxjs": "^5.1.0", "typescript": "~2.2.0", "zone.js": "^0.8.4" }, "devDependencies": { "@angular/compiler-cli": "^4.0.0", "@types/jasmine": "2.5.38", "@types/node": "~6.0.60", "bootstrap-loader": "^2.0.0-beta.20", "codelyzer": "~2.0.0", "css-loader": "^0.28.1", "jasmine-core": "~2.5.2", "jasmine-spec-reporter": "~3.2.0", "karma": "~1.4.1", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^0.2.0", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "node-sass": "^4.5.2", "protractor": "~5.1.0", "resolve-url-loader": "^2.0.2", "sass-loader": "^6.0.5", "ts-node": "~2.0.0", "tslint": "~4.5.0" }, "engines": { "node": "6.9.1", "npm": "5.3.0" } }

chiholiu10 avatar Aug 30 '17 14:08 chiholiu10

Move the "@angular/compiler-cli": "^4.0.0", to dependencies, that should do the trick!

turkingj avatar Aug 30 '17 15:08 turkingj

and @angular/cli, as that's the missing ng error. Also, change postinstall for heroku-postbuild as it achieves the same thing, but doesn't trigger a build when you're installing deps locally

intellix avatar Aug 30 '17 15:08 intellix

@turkingj Had already moved this file as you said, but I still get this error

chiholiu10 avatar Aug 30 '17 15:08 chiholiu10

@chiholiu, I was having trouble too until I changed the npm version to 3.10.9.

julianobrasil avatar Sep 19 '17 20:09 julianobrasil

@chiholiu I've moved "@angular/compiler-cli" and "@angular/cli" from DevDependencies to Dependencies. This solved the problem

saleslessa avatar Sep 30 '17 09:09 saleslessa

Working example: https://github.com/AryanJ-NYC/angular-cli-heroku-boilerplate

AryanJ-NYC avatar Dec 21 '17 15:12 AryanJ-NYC

hello, i am having this issue while deploying my angular 6 project on heroku heroku error

MuhammadHaseebKhan avatar Sep 16 '18 19:09 MuhammadHaseebKhan

and @angular/cli, as that's the missing ng error. Also, change postinstall for heroku-postbuild as it achieves the same thing, but doesn't trigger a build when you're installing deps locally

@intellix can you explain what you mean for the postinstall for heroku-postbuild

rogerprz avatar Nov 24 '18 23:11 rogerprz

This one will run after you do an npm install (which'll also work on Heroku):

"postinstall": "ng build --prod"

This one will only run the build after installing dependencies on Heroku:

"heroku-postbuild": "ng build --prod"

Obviously you don't want to build everytime you install dependencies locally so ideally you want to use heroku-postbuild for building there

intellix avatar Nov 24 '18 23:11 intellix

Closing as per @intellix answer.

alan-agius4 avatar Jan 04 '19 12:01 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.