How to fix 'failed to compile Node.js app' error on heroku
NickName:Harshil Gambhir Ask DateTime:2021-04-05T12:19:27

How to fix 'failed to compile Node.js app' error on heroku

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

More about “How to fix 'failed to compile Node.js app' error on heroku” related questions

How the type `Fix` and function `fix` are same in Haskell?

I'm trying to convince myself that type Fix and function fix are the same thing. But I can't find the correlation between their definitions -- definition of fix fix :: (p -> p) -> p fix f = ...

Show Detail

How to fix Lint problems with --fix in Firebase Functions

I'ved got a firebase Function code that has quite a lot of Lint problems. How can I fix these with --fix. It was shown at the end of the error message. firebase deploy /Users/xxx/firebase/functions/

Show Detail

How to fix this AttributeError?

I installed a stripe package yesterday and now my app is not running. I am trying to understand where the problem is. Is it something to do with PyShell or HTLParser or something else. I am posting...

Show Detail

How to fix this template:

template <typename IN,typename OUT,bool isVector> OUT foo(IN x){ if (isVector){ return x[0]; } else { return x; } } After asking this question I wrongly assu...

Show Detail

How to fix QGraphicsScene?

How to fix the QGraphicsScene? I mean, how to disable auto centering? When I try to move an object along the X axis to the right, and then return it to the left by the same axis, the center changes...

Show Detail

How to handle recursion in FIX?

Imagine a situation where you need to have recursive data structures, like trees, represented in a FIX message. How would you do that? I could represent a data structure in JSON like this: { { ...

Show Detail

How to implement a class with FIX types

Here is a working code #include "quickfix/FixFields.h" #include "quickfix/Values.h" int main() { FIX::BeginString beginString(FIX::BeginString_FIX42); return 0; } It compiles and if I

Show Detail

Not sure how to fix this bug

I am trying to convert some less to sass and can't understand how to fix the following bug. This isn't my code it's a clients and I have no clue what they are trying to do. Could someone please he...

Show Detail

A FIX msg is broken into 02 parts. How to link these broken set of FIX msgs to make it a complete FIX msg?

Lets say, we get the FIX messages from upstream system in the from of XML messages. But these messages are broken into 02 xml messages. All this msgs in xml format is stored in a table. Now, we have

Show Detail

How to fix requireShorthandArrowFunctions

How to fix this requireShorthandArrowFunctions arrow function so that it is compliant with JSCS? const doSomething = () => { return new Promise((resolve, reject) => { resolve('s...

Show Detail