Heroku-postbuild error when deploying nodejs and angular to heroku - node.js

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.

Related

how to fix npm ERR! code ELIFECYCLE (heroku)

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.

Create a docker container from an angular project

I want to create a docker container based on my angular project.
This is my dockerfile:
# here we dockerize angular app
FROM node:12-alpine3.11
WORKDIR /usr/local/lib
COPY . /usr/local/lib/
RUN npm install
RUN npm run build
EXPOSE 4200
CMD [ "node", "server.js" ]
The dockerfile is located in the directory of my angular project containing all of the files except for node_modules.
When i try to build my docker image i reach the build stage and get this error:
"./node_modules/primeng/fesm2015/primeng-chart.js:4:0-34 - Error: Module not found: Error: Can't resolve 'chart.js/auto' in '/usr/local/lib/node_modules/primeng/fesm2015'"
this is my package.json
{
"name": "acm_jenkins_web",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"sonar-scanner": "sonar-scanner"
},
"private": true,
"dependencies": {
"#angular/animations": "^12.2.2",
"#angular/cdk": "^12.2.2",
"#angular/common": "~12.0.3",
"#angular/compiler": "~12.0.3",
"#angular/core": "~12.0.3",
"#angular/forms": "~12.0.3",
"#angular/platform-browser": "~12.0.3",
"#angular/platform-browser-dynamic": "~12.0.3",
"#angular/router": "~12.0.3",
"#ngx-translate/core": "^13.0.0",
"#ngx-translate/http-loader": "^6.0.0",
"bootstrap": "^3.0.0",
"chart.js": "^2.9.4",
"jquery": "^3.6.0",
"ngx-toastr": "^14.0.0",
"popper.js": "^1.16.1",
"primeicons": "^4.1.0",
"primeng": "^12.0.0-rc.1",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "~12.0.3",
"#angular/cli": "~12.0.3",
"#angular/compiler-cli": "~12.0.3",
"#types/jasmine": "~3.6.0",
"#types/node": "^12.11.1",
"jasmine-core": "~3.7.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.5.0",
"typescript": "~4.2.3",
"sonar-scanner": "^3.1.0"
}
}
Did you try such steps on local machine (not docker)?
delete local node_modules folder completely
use npm i to install deps
run npm build on the local machine
In case you get the same issue, the reason can be installing incorrect version of this two packages and you can dig this way:
"chart.js": "^2.9.4",
...
"primeng": "^12.0.0-rc.1",
Othervise you can save package-lock.json after steps above and try to run npm ci command instead of npm install.
It should help if there's sth incorrect with deps

Angular not working after cloning to a different PC

so I got a new pc and I wanted to pass my angular project through github.
I used 1.npm i 2.npm i #angular/cli#latest -D 3. ng update
And Everytime I'm trying to run the project with ng s it keeps sending me this error:
This version of CLI is only compatible with Angular versions ^9.0.0-beta || >=9.0.0 <10.0.0,
but Angular version 8.2.14 was found instead.
Please visit the link below to find instructions on how to update Angular.
https://angular-update-guide.firebaseapp.com/
I tried using the instructions at the link.
This is my Angular version when typing ng --version:
Angular CLI: 9.0.1
Node: 12.16.0
This is the package.json:
{
"name": "empire-gaming",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-redux/store": "^10.0.0",
"#angular/animations": "~8.2.14",
"#angular/cdk": "~8.2.3",
"#angular/common": "~8.2.14",
"#angular/compiler": "~8.2.14",
"#angular/core": "~8.2.14",
"#angular/forms": "~8.2.14",
"#angular/material": "^8.2.3",
"#angular/platform-browser": "~8.2.14",
"#angular/platform-browser-dynamic": "~8.2.14",
"#angular/router": "~8.2.14",
"#ng-bootstrap/ng-bootstrap": "^5.2.1",
"#ngrx/store": "^8.6.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"hammerjs": "^2.0.8",
"mongoose": "^5.8.10",
"ngx-bootstrap": "^5.3.2",
"redux": "^4.0.5",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.22",
"#angular/cli": "^9.0.1",
"#angular/compiler-cli": "~8.2.14",
"#angular/language-service": "~8.2.14",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
I'm really clueless about it... I would be glad if you help me.
The version of Angular that you are using in the project is lower than the version that needed for the latest version of Angular CLI.
I would recommend you to downgrade the Angular CLI version to 8.3.25
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#8.3.25
And change the version of Angular CLI in your devDependencies:
npm install -D #angular/cli#8.3.25
First step install Angular globally.
npm install -g #angular/cli#latest
Run Update command to get a list of all dependencies required to be upgraded.
ng update
Next Run update command as below for each individual Angular core package
ng update #angular/cli #angular/core
If you want to force the changes use: –force and –allow-dirty flags command additionally to fix all other pending issues.
ng update #angular/cli #angular/core --allow-dirty --force
This is worked for me
Delete folder node_modules and package-lock.json
then execute: "npm install"
in short:
go to project directory in terminal/command prompt and execute following commands
rm -fr ./node_modules
rm -fr ./package-lock.json
npm install
ng serve -o
I know this is an old thread, but in my experience changing the app package.json file("#angular-devkit/build-angular") to another compatible version works for me :). After the file change, you will be needed to run again these commands "ng update", "npm install" & "ng server"

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