how to fix npm ERR! code ELIFECYCLE (heroku) - node.js

I'm currently working on a project since i've been teaching myself Angular over the past couple weeks. I wrote up my code, created what I thought I needed for deploying on heroku and tried to deploy it. I received the following error
-----> Build
Detected both "build" and "heroku-postbuild" scripts
Running heroku-postbuild
> purposefularmament#0.0.0 heroku-postbuild /tmp/build_2c8456a0
> ng build --configuration production
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! purposefularmament#0.0.0 heroku-postbuild: `ng build --configuration
production`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the purposefularmament#0.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging
output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.JjS0Q/_logs/2022-09-23T14_54_55_966Z-debug.log
-----> Build failed
after doing some research I only found that this error is caused by an issue with my npm install. I deleted my node_modules file and removed package-lock.json, cleared the npm cache and then reinstalled npm. I repushed the code and Im still getting this same error.
Any suggestions?
Here is my package.json and server.js files
{
"name": "purposefularmament",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"heroku-postbuild": "ng build --configuration production"
},
"private": true,
"dependencies": {
"#angular/animations": "~11.1.2",
"#angular/cli": "^14.2.3",
"#angular/common": "~11.1.2",
"#angular/compiler": "~11.1.2",
"#angular/compiler-cli": "^11.2.14",
"#angular/core": "~11.1.2",
"#angular/forms": "~11.1.2",
"#angular/platform-browser": "~11.1.2",
"#angular/platform-browser-dynamic": "~11.1.2",
"#angular/router": "~11.1.2",
"bootstrap": "^5.2.1",
"bootstrap-icons": "^1.9.1",
"bulma": "^0.9.4",
"express": "^4.18.1",
"grunt-express": "^1.4.1",
"node": "^14.15.0",
"path": "^0.12.7",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"typescript": "~4.1.2",
"zone.js": "~0.11.3"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.1101.4",
"#angular/cli": "^14.2.3",
"#angular/compiler-cli": "^11.2.14",
"#types/jasmine": "~3.6.0",
"#types/node": "^12.11.1",
"autoprefixer": "^10.4.8",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.2.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"postcss": "^8.4.16",
"protractor": "~7.0.0",
"tailwindcss": "^3.1.8",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.2"
},
"engines": {
"node": "14.15.0",
"npm": "6.14.13"
}
}
and server.js
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist/purposefularmament'));
app.get('/*', function(req,res) {
res.sendFile('index.html', {root: 'dist/purposefularmament/'});
});
// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);

Welp I spoke too soon, for those of you how care I fixed the issue by updating node.js to the newest latest version. I was lead to believe that both heroku and my local system should use the same node version. For whatever reason my version was behind. After adjusting for the new node version I repushed and everything worked.

Related

Could not resolve peer dependency between my Angular app and my custom Angular library

I have created this Angular library that I now want to use in my other Angular apps, but I seem to have trouble with my peer dependencies. I have tried fiddling around in my App's package.json, but couldn't seem to remove any of my errors.
What I have tried (in that order) :
Removing node_modules
ng update
npm update
npm audit --fix
npm i
Recreating a new test app all together
Here are the errors :
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: lib-test#0.0.0
npm ERR! Found: #angular/common#13.0.3
npm ERR! node_modules/#angular/common
npm ERR! #angular/common#"~13.0.0" from the root project
npm ERR! peer #angular/common#"^13.0.0 || ^14.0.0-0" from #angular/cdk#13.2.2
npm ERR! node_modules/#angular/cdk
npm ERR! #angular/cdk#"^13.2.0" from the root project
npm ERR! peer #angular/cdk#"^13.0.0" from #my-group/angular-lib#1.1.4
npm ERR! node_modules/#my-group/angular-lib
npm ERR! #my-group/angular-lib#"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #angular/common#"^13.1.0" from #my-group/angular-lib#1.1.4
npm ERR! node_modules/#my-group/angular-lib
npm ERR! #my-group/angular-lib#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
package.json (App)
{
"name": "lib-test",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"#angular/animations": "~13.0.0",
"#angular/cdk": "^13.2.2",
"#angular/common": "~13.0.0",
"#angular/compiler": "~13.0.0",
"#angular/core": "~13.0.0",
"#angular/forms": "~13.0.0",
"#angular/material": "^13.2.2",
"#angular/platform-browser": "~13.0.0",
"#angular/platform-browser-dynamic": "~13.0.0",
"#angular/router": "~13.0.0",
"#cloud-republic/angular-lib": "^1.1.4",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "~13.0.3",
"#angular/cli": "~13.0.3",
"#angular/compiler-cli": "~13.0.0",
"#types/jasmine": "~3.10.0",
"#types/node": "^12.11.1",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.4.3"
}
}
package.json (Library)
{
"name": "#my-group/angular-lib",
"version": "1.0.6",
"publishConfig": {
"#my-group:registry": "https://gitlab.com/api/v4/projects/XXXXXX/packages/npm/"
},
"scripts": {
"build-lib": "ng build lib-angular",
"semantic-release": "semantic-release"
},
"peerDependencies": {
"#angular/cdk": "^13.0.0",
"#angular/common": "^13.1.0",
"#angular/core": "^13.1.0",
"#angular/material": "^13.2.0",
"ngx-bootstrap": "^8.0.0",
"rxjs": "~7.4.0"
},
"dependencies": {
"tslib": "^2.3.0"
},
"devDependencies": {
"#semantic-release/gitlab": "^7.0.4",
"semantic-release": "^19.0.2"
}
}
Thanks in advance
This is not the issue with peer dependencies. This is more to do with version conflict. I guess you are using npm >=7 that's why you are getting this error:-
As mentioned in the error log try the below command to fix the issue:-
npm install --legacy-peer-deps
The above solution will solve your problem. However, the main issue is with your library.
In your library package you are saying use the below package:-
"#angular/common": "^13.1.0"
However, in your application, you have installed the below version.
"#angular/common": "~13.0.0".
So your library package is greater than the one installed in the application.
Either install the same version in your application or downgrade the version in your library.
In this way, npm install command will work without any issue.

Heroku-postbuild error when deploying nodejs and angular to heroku

I have a app that is currently deployed on heroku and working perfectly fine. I created a new heroku app and tried to run the same branch. I installed nodejs and all the configuration is the same but for some reason the build is failing at heroku-postbuild: "ng build --prod". It works fine on the previous instance I have on heroku but wont work on the new one. I don't know what i am missing as the information on the error is minimal. I am attaching my package.json as well as the error message I get. any help will be appreciated and let me know if you need me to upload anything else.
package.json
{
"name": "eserver",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"main": "server.js",
"heroku-postbuild": "ng build --prod",
"preinstall": "npm install -g #angular/cli #angular/compiler-cli typescript",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^11.0.5",
"#angular/cdk": "^11.0.3",
"#angular/common": "^11.0.5",
"#angular/compiler": "11.0.5",
"#angular/compiler-cli": "^11.0.5",
"#angular/core": "^11.0.5",
"#angular/flex-layout": "^11.0.0-beta.33",
"#angular/forms": "^11.0.5",
"#angular/localize": "^11.0.5",
"#angular/material": "^11.0.3",
"#angular/platform-browser": "11.0.5",
"#angular/platform-browser-dynamic": "11.0.5",
"#angular/router": "11.0.5",
"ng2-charts-schematics": "^0.1.7",
"#angular-devkit/build-angular": "^0.1100.5",
"#angular/cli": "11.0.5",
"#angular/language-service": "^11.0.5",
"#fortawesome/fontawesome-free": "^5.15.1",
"#types/chartist": "^0.11.0",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/lodash": "^4.14.135",
"#types/node": "^8.10.66",
"#types/uuid": "^8.3.0",
"angular-cli-ghpages": "^0.6.2",
"protractor": "^7.0.0",
"ts-node": "~5.0.1",
"#ng-bootstrap/ng-bootstrap": "^5.3.1",
"#ng-bootstrap/schematics": "^2.0.0-alpha.1",
"#ngtools/webpack": "^11.0.5",
"#ngx-translate/core": "13.0.0",
"#ngx-translate/http-loader": "^4.0.0",
"#types/chart.js": "^2.7.42",
"#types/express": "^4.17.0",
"#types/w3c-web-usb": "^1.0.4",
"#types/web-bluetooth": "0.0.4",
"angular-bootstrap-md": "^7.4.3",
"angular-cc-library": "^2.1.2",
"angular-notifier": "^4.1.1",
"angular-responsive-carousel": "^2.0.2",
"angular5-csv": "^0.2.11",
"apexcharts": "^3.25.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"bootstrap": "^4.5.3",
"chart.js": "^2.9.4",
"chartist": "^0.11.4",
"config": "^3.3.6",
"core-js": "^2.5.4",
"cors": "^2.8.5",
"css-loader": "^2.1.0",
"dotenv": "^6.1.0",
"exec": "^0.2.1",
"express": "^4.16.4",
"express-jwt": "^5.3.1",
"express-sslify": "^1.2.0",
"font-awesome": "^4.7.0",
"fontawesome": "^5.6.3",
"got": "^11.8.1",
"hammerjs": "^2.0.8",
"jsonwebtoken": "^8.2.2",
"ldbutton": "^1.0.2",
"lodash": "^4.17.11",
"mat-table-exporter": "^1.0.2",
"material-design-lite": "^1.3.0",
"mdb-angular-ui-kit": "^1.0.0-alpha3",
"mdbootstrap": "^4.19.2",
"mongodb": "^3.0.10",
"mongoose": "^5.1.4",
"ng-apexcharts": "^1.5.8",
"ng-chartist": "^4.1.0",
"ng-multiselect-dropdown": "^0.2.3",
"ng-thermal-print": "^1.0.3",
"ng2-charts": "^2.4.2",
"ngx-autosize": "^1.8.4",
"ngx-bootstrap": "^6.2.0",
"ngx-chess-board": "^2.0.7",
"node-sass": "^4.14.1",
"path": "^0.12.7",
"popper.js": "^1.15.0",
"pusher": "^2.2.0",
"pusher-js": "^4.4.0",
"readable-stream": "^3.6.0",
"remote-pay-cloud": "3.1.0",
"remote-pay-cloud-api": "^4.0.3",
"request": "^2.88.2",
"request-promise": "^4.2.4",
"resize-base64": "^1.0.12",
"rootpath": "^0.1.2",
"rxjs": "^6.5.2",
"rxjs-compat": "^6.3.3",
"time-ago-pipe": "^1.3.2",
"tslib": "^1.9.0",
"typescript": "4.0.5",
"uuid": "^3.3.2",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.3"
},
"devDependencies": {
"#angular-devkit/core": "^11.0.5",
"#angular-devkit/schematics": "^11.0.5",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"ng2-charts-schematics": "^0.1.7",
"protractor": "^7.0.0",
"ts-node": "~5.0.1",
"tslint": "~6.1.3"
},
"engines": {
"node": "10.13",
"npm": "6.9.0"
}
}
log and Error I am getting when deploying on heroku:
Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 10.13
engines.npm (package.json): 6.9.0
Resolving node version 10.13...
Downloading and installing node 10.13.0...
Bootstrapping npm 6.9.0 (replacing 6.4.1)...
npm 6.9.0 installed
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules (package.json)
> eserver#0.0.0 preinstall /tmp/build_d00ecea7
> npm install -g #angular/cli #angular/compiler-cli typescript
/tmp/build_d00ecea7/.heroku/node/bin/ng -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/cli/bin/ng.js
/tmp/build_d00ecea7/.heroku/node/bin/ngcc -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/compiler-cli/bundles/ngcc/main-ngcc.js
/tmp/build_d00ecea7/.heroku/node/bin/ngc -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/compiler-cli/bundles/src/bin/ngc.js
/tmp/build_d00ecea7/.heroku/node/bin/ng-xi18n -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/compiler-cli/bundles/src/bin/ng_xi18n.js
/tmp/build_d00ecea7/.heroku/node/bin/tsc -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/typescript/bin/tsc
/tmp/build_d00ecea7/.heroku/node/bin/tsserver -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/typescript/bin/tsserver
> #angular/cli#13.1.4 postinstall /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/cli
> node ./bin/postinstall/script.js
+ #angular/cli#13.1.4
+ typescript#4.5.5
+ #angular/compiler-cli#13.1.3
added 271 packages from 168 contributors in 10.621s
audited 2004 packages in 17.813s
found 45 vulnerabilities (2 low, 26 moderate, 17 high)
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
Detected both "build" and "heroku-postbuild" scripts
Running heroku-postbuild
> eserver#0.0.0 heroku-postbuild /tmp/build_d00ecea7
> npm i && ng build --prod
> eserver#0.0.0 preinstall /tmp/build_d00ecea7
> npm install -g #angular/cli #angular/compiler-cli typescript
/tmp/build_d00ecea7/.heroku/node/bin/ng -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/cli/bin/ng.js
/tmp/build_d00ecea7/.heroku/node/bin/ngc -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/compiler-cli/bundles/src/bin/ngc.js
/tmp/build_d00ecea7/.heroku/node/bin/ng-xi18n -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/compiler-cli/bundles/src/bin/ng_xi18n.js
/tmp/build_d00ecea7/.heroku/node/bin/ngcc -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/compiler-cli/bundles/ngcc/main-ngcc.js
/tmp/build_d00ecea7/.heroku/node/bin/tsc -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/typescript/bin/tsc
/tmp/build_d00ecea7/.heroku/node/bin/tsserver -> /tmp/build_d00ecea7/.heroku/node/lib/node_modules/typescript/bin/tsserver
> #angular/cli#13.1.4 postinstall /tmp/build_d00ecea7/.heroku/node/lib/node_modules/#angular/cli
> node ./bin/postinstall/script.js
+ #angular/compiler-cli#13.1.3
+ #angular/cli#13.1.4
+ typescript#4.5.5
updated 3 packages in 3.453s
audited 2004 packages in 11.332s
found 45 vulnerabilities (2 low, 26 moderate, 17 high)
run `npm audit fix` to fix them, or `npm audit` for details
'node-sass' usage is deprecated and will be removed in a future major version. To opt-out of the deprecated behaviour and start using 'sass' uninstall 'node-sass'.
- Generating browser application bundles...
✔ Browser application bundle generation complete.
Error: compiler_1.getMissingNgModuleMetadataErrorData is not a function
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! eserver#0.0.0 heroku-postbuild: `npm i && ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the eserver#0.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.CSj5i/_logs/2022-01-26T03_37_12_096Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Check if HEROKU_API_KEY is correct and that heroku_app_name is unique. Also this line seems sketcy: Detected both "build" and "heroku-postbuild" scripts Running heroku-postbuild. Maybe refactor heroku-postbuild in build and run only build.
"scripts": {
"ng": "ng",
"main": "server.js",
"preinstall": "npm install -g #angular/cli #angular/compiler-cli typescript",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
I managed to solve the issue by changing the version of #angular/compiler-cli and #angular/compiler versions.

Failed Heroku deploy: sh: 1: ng: not found

Failed Heroku deploy. Been looking at other similar stack overflow posts and changing package.json file trying solutions that have worked for others with no luck. I am not sure if this is a port issue, or a package.json issue or something completely different. Any help, tips or advice is greatly appreciated!
Heroku logs:
2019-02-09T08:32:56.609533+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-09T08:33:00.956199+00:00 heroku[web.1]: Starting process with command `npm start`
2019-02-09T08:33:03.430137+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-09T08:33:03.257739+00:00 app[web.1]:
2019-02-09T08:33:03.257781+00:00 app[web.1]: > the-lottery-genie-mean#0.0.0 start /app
2019-02-09T08:33:03.257783+00:00 app[web.1]: > ng serve
2019-02-09T08:33:03.257784+00:00 app[web.1]:
2019-02-09T08:33:03.294426+00:00 app[web.1]: sh: 1: ng: not found
2019-02-09T08:33:03.304958+00:00 app[web.1]: npm ERR! file sh
2019-02-09T08:33:03.305986+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-02-09T08:33:03.306367+00:00 app[web.1]: npm ERR! errno ENOENT
2019-02-09T08:33:03.309015+00:00 app[web.1]: npm ERR! syscall spawn
2019-02-09T08:33:03.310700+00:00 app[web.1]: npm ERR! the-lottery-genie-mean#0.0.0 start: `ng serve`
2019-02-09T08:33:03.310912+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-02-09T08:33:03.311266+00:00 app[web.1]: npm ERR!
2019-02-09T08:33:03.311514+00:00 app[web.1]: npm ERR! Failed at the the-lottery-genie-mean#0.0.0 start script.
2019-02-09T08:33:03.314421+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-02-09T08:33:03.324652+00:00 app[web.1]:
2019-02-09T08:33:03.324892+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-02-09T08:33:03.325013+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-02-09T08_33_03_316Z-debug.log
2019-02-09T08:33:03.411224+00:00 heroku[web.1]: Process exited with status 1
package.json:
{
"name": "the-lottery-genie-mean",
"version": "0.0.0",
"scripts": {
"preinstall": "npm link #angular/cli ",
"heroku-postbuild": "ng build --prod",
"postinstall": "",
"ng": "ng",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/cli": "^7.1.4",
"#angular/compiler-cli": "~7.0.0",
"#angular/animations": "~7.0.0",
"#angular/common": "~7.0.0",
"#angular/compiler": "~7.0.0",
"#angular/core": "~7.0.0",
"#angular/forms": "~7.0.0",
"#angular/http": "~7.0.0",
"#angular/platform-browser": "~7.0.0",
"#angular/platform-browser-dynamic": "~7.0.0",
"#angular/router": "~7.0.0",
"core-js": "^2.5.4",
"json": "^9.0.6",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.13.1",
"#angular/language-service": "~7.0.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
},
"engines": {
"node": "10.15.1",
"npm": "6.4.1"
}
}
server.js file
app.listen(PORT, '0.0.0.0', function () {
console.log("Node app is running at localhost:" + app.get('port'));
})
Did you check the debug log here /app/.npm/_logs/2019-02-09T08_33_03_316Z-debug.log ?
I suggest looking into the debug log first to get us more details to solve the problem.
UPDATE
Its an H10 error. "heroku[router]: at=error code=H10 desc="App crashed"
method=GET path="/favicon.ico" host=angular-lottery-genie.herokuapp.com
request_id=30e63a79-c395-4d2a-9987-938bcc350629 fwd="50.250.113.70" dyno=
connect= service= status=503 bytes= protocol=https"
Your app crashed. Here are some things you can do:
1.) Restart heroku. You should have heroku CLI installed. Here's the link: Heroku CLI Install . And run heroku restart on your terminal.
2.) Use port that Heroku dynamically sets which can be accessed usually at process.env.PORT, and set your desired port as backup:
app.listen(process.env.PORT || 3000, function(){
console.log("Node app is running at localhost:" + app.get('port'));
});
3.) Try to check your node and npm version by typing in your terminal:
node --version
npm --version
And update the node and npm versions indicated under your package.json file:
"engines": {
"node": "10.15.1",
"npm": "6.4.1"
}
Another UPDATE for your questions:
npm ERR! enoent ENOENT: no such file or directory
These errors are usually related to corruption or incompatibility of packages. What you can do:
1.) Make sure no other instances of node are running in the backgound and retry your npm command.
2.) Delete the node_modules directory and package-lock.json (if you have any). Reinstall packages running npm install (or any command you're using to install the packages) in your terminal inside your project directory.
3.) Upgrade node to the latest version, delete node_modules directory and package-lock.json, and reinstall the packages.
4.) If npm still does not work for you, try yarn package manager (Yarn).
5.) If packages installation still fail, check the error logs file for a detailed report of the error.
Hope this helps!
You might need to add the devkit/builder, make sure its in the right sequence. I added it in bold so make sure if you are gonna copy paste to remove the asterix from the beginning and end.
"#angular/cli": "^7.1.4",
"#angular/compiler-cli": "~7.0.0",
"#angular/animations": "~7.0.0",
"#angular/common": "~7.0.0",
"#angular/compiler": "~7.0.0",
"#angular/core": "~7.0.0",
"#angular/forms": "~7.0.0",
"#angular/http": "~7.0.0",
"#angular/platform-browser": "~7.0.0",
"#angular/platform-browser-dynamic": "~7.0.0",
"#angular/router": "~7.0.0",
**"#angular-devkit/build-angular": "^0.13.1",
"#angular/language-service": "~7.0.0",**
"core-js": "^2.5.4",
"json": "^9.0.6",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"
In my experience, the deployment of an app that works locally is not always straightforward in Heroku. There are several cases like this in StackOverflow without a definitive solution, specially related to "'library' not found". For someone with a similar problem (trying to deploy AngularJS in Heroku) I would recommend check first functional tutorials like these:
https://devcenter.heroku.com/articles/mean-apps-restful-api
Almost-Oficial documentation. It describes a more complex app but you can discard some things.
https://medium.com/better-programming/how-to-deploy-your-angular-9-app-to-heroku-in-minutes-51d171c2f0d This guy shows a working Angular tutorial deployed in Heroku.
move some devDependencies to dependencies (angular 9 example)
npm i #angular/cli #angular-devkit/build-angular #angular/compiler-cli typescript --save-prod
or set NPM_CONFIG_PRODUCTION to false
here is an answer to similar question

Npm install error EPERM Operation not permitted

So when trying to run the angular4 project today my first error was : npm install eperm operation not permitted so I thought to delete my node modules folder and retry. But running npm install I am running in to this error npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start". I've closed vscode to try and run the install to make sure nothing was locking it. I've tried npm cache clean but results in errors.
Todays latest struggles :
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-
cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli '#angular/cli#latest' ]
2 info using npm#5.5.1
3 info using node#v8.9.3
4 verbose npm-session 2a0bb102467943cf
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 error cb() never called!
Admin Results:
Any suggestions?
My package.json looks like this :
{
"name": "gamemanagement",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.0.1",
"#angular/cdk": "^5.0.0-rc0",
"#angular/common": "^5.0.1",
"#angular/compiler": "^5.0.1",
"#angular/compiler-cli": "^5.0.1",
"#angular/core": "^5.0.1",
"#angular/forms": "^5.0.1",
"#angular/http": "^5.0.1",
"#angular/material": "^5.0.0-rc0",
"#angular/platform-browser": "^5.0.1",
"#angular/platform-browser-dynamic": "^5.0.1",
"#angular/platform-server": "^5.0.1",
"#angular/router": "^5.0.1",
"#ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"angular2-moment": "^1.7.0",
"angular2-text-mask": "^8.0.4",
"angularfire2": "5.0.0-rc.3",
"ap-angular2-fullcalendar": "^1.3.5",
"bootstrap": "4.0.0-beta",
"core-js": "^2.4.1",
"firebase": "4.6.2",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"moment": "^2.19.3",
"ng2-date-picker": "^2.6.2",
"popper.js": "^1.12.9",
"rxjs": "^5.4.2",
"sweetalert2": "^7.0.9",
"typescript": "^2.6.1",
"zone.js": "^0.8.14"
},
"devDependencies": {
"#angular/cli": "^1.5.3",
"#angular/compiler-cli": "^4.2.4",
"#angular/language-service": "^4.2.4",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.3.3"
}
}
I had the same issue. After cache clean and updating npm everything is ok. So try to run:
npm cache clean --force
npm install -g npm#latest
There are 2 solutions for this
you can run "npm cache clean"
you run the command prompt in admin mode.
macOS catalina ,
npm init
got error
operation not permitted, uv_cwd
step 1: go to parent folder
cd ../
step 2: go to your project folder again,
cd your-project-folder
That is it. it works.
Try below setps, hope this helps.
Update Node.js
npm cache clean command in Command prompt, try as admin
check node proxy settings if persist remove them with below
npm config delete http-proxy
npm config delete https-proxy
Install by yourself the module that is giving the error.
After spending many hours and trying all the possible suggestions, I found that installing the specific module mentioned by the error globally fixed the issue:
For Example:
npm ERR! { Error: EPERM: operation not permitted, unlink 'Path\Docume
nts\AngularProjects\my-sample-app333\node_modules.staging#angular\core-a3d1aa4
8\ bundles\core.umd.js
I run: npm install -global #angular/core
and it fixed it for me! Finally!!
Just try npm cache clean quick and simple :)
I tried everything above but it did not work for me.
I copied all content of package.json and deleted the file. Then, I created a new file and copied all there and I saved it as package.json
That fixed everything
100% sure
Firstly delete the project folder. eg: myapp1
Then run ->npm cache clean --force command
Retype the command that gives error previously.
I also faced the same issue but once I removed node_modules folder along with package-lock.json from the project and then I re-installed entire thing again with npm i it worked for me.

Heruku Deploy Error Angular

I am getting this error while I upload ng project. When I am localy it works fines. When I upload it to Heruku I get this error.
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 8.1.4
engines.npm (package.json): unspecified (use default)
Resolving node version 8.1.4...
Downloading and installing node 8.1.4...
Detected package-lock.json: defaulting npm to version 5.x.x
Bootstrapping npm 5.x.x (replacing 5.0.3)...
npm 5.3.0 installed
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Installing node modules (package.json + package-lock)
> orahi-dash-board#0.0.0 preinstall /tmp/build_69fc13367426455c989d318ff32b98f2
> npm install -g http-server
/tmp/build_69fc13367426455c989d318ff32b98f2/.heroku/node/bin/http-server -> /tmp/build_69fc13367426455c989d318ff32b98f2/.heroku/node/lib/node_modules/http-server/bin/http-server
/tmp/build_69fc13367426455c989d318ff32b98f2/.heroku/node/bin/hs -> /tmp/build_69fc13367426455c989d318ff32b98f2/.heroku/node/lib/node_modules/http-server/bin/http-server
+ http-server#0.10.0
added 23 packages in 2.902s
> orahi-dash-board#0.0.0 postinstall /tmp/build_69fc13367426455c989d318ff32b98f2
> ng build --aot -prod
sh: 1: ng: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! orahi-dash-board#0.0.0 postinstall: `ng build --aot -prod`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the orahi-dash-board#0.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /app/.npm/_logs/2017-08-02T03_59_17_505Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
What might be the issue?
Here is my package.json
{
"name": "",
"version": "0.0.0",
"license": "MIT",
"engines": {
"node": "8.1.4"
},
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "http-server",
"lint": "tslint \"src/**/ *.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"preinstall": "npm install -g http-server",
"postinstall": "ng build --aot -prod",
"start-dev": "ng serve"
},
"private": true,
"dependencies": {
"#angular/animations": "^4.3.2",
"#angular/common": "^4.3.2",
"#angular/compiler": "^4.3.2",
"#angular/compiler-cli": "^4.3.2",
"#angular/core": "^4.3.2",
"#angular/forms": "^4.3.2",
"#angular/http": "^4.3.2",
"#angular/material": "2.0.0-beta.2",
"#angular/platform-browser": "^4.3.2",
"#angular/platform-browser-dynamic": "^4.3.2",
"#angular/platform-server": "^4.3.2",
"#angular/router": "^4.3.2",
"#angular/tsc-wrapped": "^0.5.0",
"#ngrx/core": "^1.2.0",
"#ngrx/store": "^2.2.2",
"angular2-datatable": "0.6.0",
"angular2-google-maps": "0.17.0",
"core-js": "2.4.1",
"express": "^4.15.3",
"hammerjs": "^2.0.8",
"install": "^0.10.1",
"ng2-img-cropper": "0.8.0",
"npm": "^5.0.3",
"rxjs": "^5.4.2",
"typescript": "^2.4.2",
"zone.js": "0.7.6"
},
"devDependencies": {
"#angular/cli": "^1.2.6",
"#types/hammerjs": "^2.0.34",
"#types/jasmine": "2.5.38",
"#types/node": "6.0.60",
"codelyzer": "2.0.0-beta.4",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "3.2.0",
"karma": "1.4.1",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "0.2.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"ngrx-store-freeze": "^0.1.9",
"protractor": "5.1.0",
"ts-node": "2.0.0",
"tslint": "4.4.2"
}
}
Angular dependencies are added to your devDependencies by default. Heroku doesn't install dev dependencies when deploying, so those dependencies need to be moved into the regular dependencies section of your package.json. See 'Move the #angular/cli Dependency' on this guide: https://medium.com/#ryanchenkie_40935/angular-cli-deployment-host-your-angular-2-app-on-heroku-3f266f13f352

Resources