So I created a Mern project and wanted it to deploy on heroku. But the push is being rejected whatever I do. It always end up with an error "Push rejected, failed to compile Node.js app."
Here's my package.json file:
{
"name": "ecom",
"version": "1.0.0",
"description": "e-commerce Website",
"main": "server.js",
"engines": {
"node": "10.16.0"
},
"scripts": {
"start": "node backend/server.js",
"server": "nodemon backend/server.js",
"client": "npm start --prefix frontend",
"build": "npm install --prefix frontend && npm run build --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"data:import": "node backend/seederScript.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"date-fns": "^2.19.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.12.2",
"react-scripts": "^4.0.3"
},
"devDependencies": {
"concurrently": "^6.0.0",
"nodemon": "^2.0.7"
}
}
Here's my github repository : https://github.com/gambhir-harshil/E-commerce
Here's the complete log of the error:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> 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.16.0
engines.npm (package.json): unspecified (use default)
Resolving node version 10.16.0...
Downloading and installing node 10.16.0...
Using default npm version: 6.9.0
-----> Installing dependencies
Installing node modules
> [email protected] postinstall /tmp/build_8817a311/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> [email protected] postinstall /tmp/build_8817a311/node_modules/ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
> [email protected] postinstall /tmp/build_8817a311/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_8817a311/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_8817a311/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 1930 packages in 24.695s
-----> Build
Running build
> [email protected] build /tmp/build_8817a311
> npm install --prefix frontend && npm run build --prefix frontend
> [email protected] postinstall /tmp/build_8817a311/frontend/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_8817a311/frontend/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_8817a311/frontend/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
> [email protected] postinstall /tmp/build_8817a311/frontend/node_modules/ejs
> node ./postinstall.js
added 1885 packages from 819 contributors and audited 1889 packages in 52.962s
found 0 vulnerabilities
> [email protected] build /tmp/build_8817a311/frontend
> react-scripts build
Creating an optimized production build...
Failed to compile.
./node_modules/@material-ui/icons/utils/createSvgIcon.js
Cannot find module: '@material-ui/core/utils'. Make sure this package is installed.
You can install this package by running: npm install @material-ui/core/utils.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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.pNfTf/_logs/2021-04-05T04_59_12_835Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `npm install --prefix frontend && npm run build --prefix frontend`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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.pNfTf/_logs/2021-04-05T04_59_12_851Z-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
Some possible problems:
- A module may be missing from 'dependencies' in package.json
https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Copyright Notice:Content Author:「Harshil Gambhir」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/66948199/how-to-fix-failed-to-compile-node-js-app-error-on-heroku