You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法向Heroku推送代码:推送被拒,Node.js应用编译失败

Troubleshooting Heroku Deployment Failure for Your Express + React (Compass) App

Hey there, let’s walk through some key checks to figure out why your code isn’t pushing to Heroku. Based on the details you shared, here are the most likely areas to investigate:

  • Fix your engines.npm configuration first
    Heroku relies on specified Node.js and npm versions to build your app, and a truncated engines.npm entry could lead to version mismatches. Node.js 9.11.1 is compatible with npm 5.6.0, so update your package.json to include a full engines block like this:

    "engines": {
      "node": "9.11.1",
      "npm": "5.6.0"
    }
    

    Commit this change and try pushing again—version inconsistencies are a super common culprit here.

  • Dig into the full Heroku build logs
    The brief environment details you shared don’t show the actual error. Run heroku logs --tail in your terminal to stream the complete build process. Look for keywords like "error", "failed", or "Compass"—this will tell you exactly where things are breaking, whether it’s a missing dependency, a Grunt task failure, or a Compass compilation issue.

  • Validate your buildpack compatibility
    The buildpack you’re using is tailored for Node + Grunt + Compass setups, but double-check that it supports Node.js 9.11.1. You can also test your build locally first with heroku local—if it fails locally too, you’ll be able to debug the issue faster without pushing to Heroku every time.

  • Check your production build dependencies
    Heroku defaults to installing only dependencies (not devDependencies) in production. If your Compass or Grunt tasks rely on packages listed in devDependencies, you’ll need to either move those packages to dependencies or set the NPM_CONFIG_PRODUCTION=false environment variable in Heroku (though the former is the cleaner long-term fix).

  • Confirm all critical files are committed
    Make sure you’ve pushed every file needed for the build: Gruntfile.js, your Compass config.rb, package-lock.json (or yarn.lock), and all your React/Express source files. Missing any of these can cause Heroku to fail mid-build without clear feedback.

内容的提问来源于stack exchange,提问作者Quentin Laffont

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:20:32