heroku部署使用nodejs失败

我正试图推送本地文件到heroku并获得低于错误。 我有我的代码在github

有人可以帮助我吗? 谢谢

$ heroku buildpacks:set heroku/nodejs Buildpack set. Next release on haz will use heroku/nodejs. Run git push heroku master to create a new release using this buildpack. $ git push heroku master Counting objects: 693, done. Delta compression using up to 8 threads. Compressing objects: 100% (500/500), done. Writing objects: 100% (693/693), 63.10 MiB | 2.54 MiB/s, done. Total 693 (delta 220), reused 639 (delta 171) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Using set buildpack heroku/nodejs remote: remote: ! Push rejected, failed to detect set buildpack heroku/nodejs remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure remote: remote: Verifying deploy.... remote: remote: ! Push rejected to haz. remote: To https://git.heroku.com/haz.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/haz.git' $ 

为package.json

 { "name": "haz", "version": "1.0.0", "description": "Hazzir: An Ionic project", "private": "true", "dependencies": { "express": "^4.13.3" }, "main": "serve.js", "scripts": { "start": "node serve.js", "postinstall": "bower install && grunt build", "test": "echo \"Error: no test specified\" && exit 1" }, "engines": { "node": "4.1.2", "npm": "3.4.0" }, "keywords": [ "Haz", "product" ], "author": "Asim Khan", "license": "ISC", "bugs": { "url": "https://github.com/asimkh/apps/issues" }, "homepage": "https://github.com/asimkh/apps#readme" } 

我在本地进行testing,应用程序运行在端口5000使用快递

 var express = require('express'), app = express(); app.use(express.static('www')); // CORS (Cross-Origin Resource Sharing) headers to support Cross-site HTTP requests app.all('*', function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); next(); }); // API Routes // app.get('/blah', routeHandler); app.set('port', process.env.PORT || 5000); app.listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); }); 

我在这里看到一些问题

1)你需要一个procfile – https://devcenter.heroku.com/articles/getting-started-with-nodejs#define-a-procfile

2)你不要在你的package.json中指定引擎

 "engines": { "node": "0.10.x" }, 

见这里 – https://discussion.heroku.com/t/the-official-node-js-buildpack-is-going-on-a-diet/100

3)你已经把你的node_modules目录node_modules了git。 你应该可以使用npm install下载软件包(这就是你的packages.json文件的用途)

删除这个目录,并提交删除git。 然后,创build一个.gitignore文件。 .gitignore下行添加到.gitignore文件中:

 node_modules 

将这个.gitignore文件提交到你的仓库。

Git现在将忽略你的node_modules_目录

尝试:git add -f package.json它为我工作。

git init然后读取heroku远程工作

 heroku git:remote -a yourappname