heroku部署使用nodejs失败 [英] heroku deploy failed using nodejs
问题描述
我正在尝试将本地文件推送到英文字母,并得到下面的错误。
我有代码在 github
I am trying to push local files to heroku and getting below error. I have my code in 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'
$
for package.json
for 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"
}
我在本地测试过,应用程序在5000端口使用快递
I tested locally, app is runnning at port 5000 using express
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
1) You need a procfile - https://devcenter.heroku.com/articles/getting-started-with-nodejs#define-a-procfile
2)
您不要在package.json中指定引擎
2) You don't specify the engines in your package.json
"engines": {
"node": "0.10.x"
},
参见here- https://discussion.heroku.com / t / the-official-node-js-buildpack-is-going-on-a-diet / 100
3) code> node_modules 目录为git。你应该能够使用 npm install
(这就是你的 packages.json
文件)来下载包
3) You have comitted your node_modules
directory to git. You should be able to download packages using npm install
(that's what your packages.json
file is for)
删除此目录,并将删除提交到git。
然后,创建一个 .gitignore
文件。将以下行添加到您的 .gitignore
文件中:
Delete this directory, and commit the delete to git.
Then, create a .gitignore
file. Add the following line to your .gitignore
file:
node_modules
将此.gitignore文件提交到您的存储库。
commit this .gitignore file to your repository.
Git现在将忽略您的 node_modules _
目录
Git will now ignore your node_modules_
directory
这篇关于heroku部署使用nodejs失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!