Push rejected, failed to compile Node.js app heroku

前端 未结 8 1019
面向向阳花
面向向阳花 2020-12-09 18:01

When I tried to push my nodejs app to heroku with git push heroku master, i got this:

Counting objects: 975, done.
Delta compression using up to         


        
相关标签:
8条回答
  • I am working in ReactJS and I am trying to deploy my project on Heroku server. At that time I have found same error like this:

    Push rejected, failed to compile Node.js app.

    Solution is:

    If you use yarn:

    git rm yarn.lock

    git push heroku master

    If you use npm:

    git rm package-lock.json

    git push heroku master

    0 讨论(0)
  • 2020-12-09 18:17

    Adding node_modules may be easy but not the correct approach here. Instead do git push -f heroku master in order to FORCE push your updates telling heroku to overwrite any pre-existing node_modules. This way your git repo is not bogged down with node libs.

    0 讨论(0)
  • 2020-12-09 18:18

    Issue When you use Yarn to install node modules, it generates a yarn.lock file which contains a list of the exact modules that it installed when you ran the command. If the dependencies in package.json change, but a new yarn.lock file is not generated by the Yarn executable we fail the build to prevent subtle bugs and security issues that could affect your application at runtime.

    Resolution This issue commonly occurs when your application uses Yarn but some other tool modifies the package.json file without invoking yarn install. An example would be using npm to install a new module instead of Yarn, or manually updating a version requirement by hand.

    To resolve this, run yarn install and check in the updated yarn.lock file.

    ensure you have removed package.lock file and commited the same before push.

    0 讨论(0)
  • 2020-12-09 18:19

    I fixed it by join to the path of an imported module that did not belong to Node. More info here https://stackoverflow.com/a/64772154/12982656

    0 讨论(0)
  • 2020-12-09 18:20

    Try setting a heroku-postbuild script to your package.json and make sure to include your engines.

    "scripts": {
            "heroku-postbuild": "npm run build"
        },
    "engines": {
            "npm": "5.6.0",
            "node": "8.10.0"
          }
    

    I would try and avoid force pushing anything at all costs whether it be to github or heroku.

    0 讨论(0)
  • 2020-12-09 18:29

    I had the same issue , the problem was with git add. I had forgotten to add the node_modules files. I closed the terminal and ran the set of commands given in the Getting started with Heroku and NodeJs[1] again. The application was successfully pushed onto the stack.

    0 讨论(0)
提交回复
热议问题