0

I'm trying to push my nodejs, express (backend) and react (font end) with git push heroku master.

But have rejected:

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  10.15.1
       engines.npm (package.json):   6.4.1

       Resolving node version 10.15.1...
       Downloading and installing node 10.15.1...
       npm 6.4.1 already installed with node

-----> Restoring cache
       - node_modules

-----> Building dependencies
       Installing node modules (package.json)
       removed 231 packages and audited 201 packages in 3.657s
       found 0 vulnerabilities

       Running heroku-postbuild

       > twituet@1.0.0 heroku-postbuild /tmp/build_fcf0465a8c2c68ad9a71497722565a7a
       > cd client && npm && npm run build


       Usage: npm <command>

       where <command> is one of:
           access, adduser, audit, bin, bugs, c, cache, ci, cit,
           completion, config, create, ddp, dedupe, deprecate,
           dist-tag, docs, doctor, edit, explore, get, help,
           help-search, hook, i, init, install, install-test, it, link,
           list, ln, login, logout, ls, outdated, owner, pack, ping,
           prefix, profile, prune, publish, rb, rebuild, repo, restart,
           root, run, run-script, s, se, search, set, shrinkwrap, star,
           stars, start, stop, t, team, test, token, tst, un,
           uninstall, unpublish, unstar, up, update, v, version, view,
           whoami

       npm <command> -h  quick help on <command>
       npm -l            display full usage info
       npm help <term>   search for help on <term>
       npm help npm      involved overview

       Specify configs in the ini-formatted file:
           /app/.npmrc
       or on the command line via: npm <command> --key value
       Config info can be viewed via: npm help config

       npm@6.4.1 /tmp/build_fcf0465a8c2c68ad9a71497722565a7a/.heroku/node/lib/node_modules/npm
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! twituet@1.0.0 heroku-postbuild: `cd client && npm && npm run build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the twituet@1.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.x0XkK/_logs/2019-02-24T14_05_47_120Z-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

Here is my package.json

{
    "name": "twituet",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "node index.js",
        "heroku-postbuild": "cd client && npm && npm run build"
    },
    "keywords": [],
    "author": "vuong xuan",
    "license": "ISC",
    "dependencies": {
        "body-parser": "^1.18.3",
        "cors": "^2.8.5",
        "express": "^4.16.4",
        "mongoose": "^5.4.14",
        "morgan": "^1.9.1"
    },
    "engines": {
        "node": "10.15.1",
        "npm": "6.4.1"
    }
}

What i'm doing wrong. Pls help me...

I tried this solution but it didnt work Push rejected, failed to compile Node.js app heroku

dinosaur
  • 169
  • 1
  • 9

2 Answers2

2

Since you are executing npm command without passing any argument that is why is failing.

Look at this line "heroku-postbuild": "cd client && npm && npm run build"

And change it to "heroku-postbuild": "cd client && npm install && npm run build"

npm <command> is the correct format of npm commands.

For more details, you can refer the npm doc - https://docs.npmjs.com/cli/npm

Ashvin777
  • 1,446
  • 13
  • 19
0

Use "heroku-postbuild": "echo Skip builds on Heroku"

This fixed my problem!