无法向Heroku推送代码:推送被拒,Node.js应用编译失败
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.npmconfiguration first
Heroku relies on specified Node.js and npm versions to build your app, and a truncatedengines.npmentry could lead to version mismatches. Node.js 9.11.1 is compatible with npm 5.6.0, so update yourpackage.jsonto 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. Runheroku logs --tailin 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 withheroku 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 onlydependencies(notdevDependencies) in production. If your Compass or Grunt tasks rely on packages listed indevDependencies, you’ll need to either move those packages todependenciesor set theNPM_CONFIG_PRODUCTION=falseenvironment 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 Compassconfig.rb,package-lock.json(oryarn.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

