Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku deploy issue sh: 1: ng: not found?

Tags:

angular

heroku

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.

like image 412
Kanna Avatar asked Oct 23 '17 08:10

Kanna


People also ask

Does Heroku automatically npm install?

By default, Heroku runs npm start while starting deployed Node. js applications, but if you would like to run some other script from your package. json instead you just need to follow one simple step.

How do I manually deploy to Heroku?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.


2 Answers

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/[email protected] @angular-devkit/[email protected] @angular/[email protected] [email protected] --save-prod

issue by github

like image 140
ya_dimon Avatar answered Oct 18 '22 03:10

ya_dimon


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

like image 24
nilansh bansal Avatar answered Oct 18 '22 03:10

nilansh bansal