13

I'm facing some issues while running app in heroku.

Log:

 2017-10-22T20:41:16.421991+00:00 app[web.1]: npm ERR! errno ENOENT
 2017-10-22T20:41:16.411165+00:00 app[web.1]: > ng serve
 2017-10-22T20:41:16.411149+00:00 app[web.1]: 
 2017-10-22T20:41:16.421630+00:00 app[web.1]: npm ERR! file sh
 2017-10-22T20:41:16.411165+00:00 app[web.1]: 
 2017-10-22T20:41:16.416314+00:00 app[web.1]: sh: 1: ng: not found

package.json:

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
},

Env:

Angular 4, and I'm not using NodeJS express. I have deployed app in Heroku.

boop_the_snoot
  • 2,941
  • 3
  • 27
  • 43
Kanna
  • 960
  • 11
  • 30
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Oct 23 '17 at 10:29

2 Answers2

7

you can let heroku build your dev dependencies by setting environment: NPM_CONFIG_PRODUCTION to false. (how?)


or you can move (angular 9)
@angular/cli,
@angular/compiler-cli
@angular-devkit/build-angular
typescript
from devDependencies to dependencies.

so, run:

 npm i @angular/cli @angular-devkit/build-angular @angular/compiler-cli typescript --save-prod

or with your versions, if you specified some. e.g.:

 npm i @angular/cli@9.1.x @angular-devkit/build-angular@0.901.x @angular/compiler-cli@9.1.x typescript@3.8.x --save-prod

issue by github

ya_dimon
  • 2,835
  • 2
  • 26
  • 39
2

In production environment, Angular code is deployed as static code.

Simply run:

ng build --prod --aot

Deploy the dist folder generated as the static website.

Refer: https://www.youtube.com/watch?v=jw1RtGJKIbw

nilansh bansal
  • 1,284
  • 1
  • 9
  • 23