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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With