在Heroku中使用npm和Node的Git依赖关系

我有这个package.json文件:

{ "name": "application-name" , "version": "0.0.1" , "private": true , "dependencies": { "coffee-script": "1.1.3" , "express": "2.5.0" , "less": "1.1.5" , "jade": "0.17.0" , "connect-redis": "1.2.0" , "hiredis": "0.1.13" , "redis": "0.7.1" , "bcrypt": "0.4.1" , "promised-io": "0.3.0" , "jugglingdb": "git://github.com/juggy/jugglingdb.git#master" , "nodemailer": "0.2.3" } } 

我想部署到Heroku。 它在npm版本1.0.105本地正常工作,但它扼住了Heroku(我更新了npm到1.0.105):

  -----> Heroku receiving push -----> Fetching custom build pack... done -----> Node.js app detected -----> Fetching Node.js binaries -----> Vendoring node 0.4.7 -----> Installing dependencies with npm 1.0.105 npm ERR! git checkout master fatal: Not a git repository: '.' npm ERR! Error: `git "checkout" "master"` failed with 128 npm ERR! at ChildProcess.<anonymous> (/tmp/node-npm-Jb2d/lib/utils/exec.js:49:20) npm ERR! at ChildProcess.emit (events.js:67:17) npm ERR! at ChildProcess.onexit (child_process.js:192:12) npm ERR! Report this *entire* log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <npm-@googlegroups.com> npm ERR! npm ERR! System Linux 2.6.32-316-ec2 npm ERR! command "/tmp/node-node-C3jD/bin/node" "/tmp/node-npm-Jb2d/cli.js" "install" npm ERR! cwd /tmp/build_2yzg7lk83o5m9 npm ERR! node -v v0.4.7 npm ERR! npm -v 1.0.105 npm ERR! git checkout master fatal: Not a git repository: '.' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /tmp/build_2yzg7lk83o5m9/npm-debug.log npm not ok ! Failed to install dependencies with npm ! Heroku push rejected, failed to compile Node.js app 

另外,我似乎没有find方法来访问/ tmp中的日志文件。

任何人都成功部署了Heroku的Git依赖(在Ruby方面工作正常:P)?

问题在于他们的nodejs buildpack。 我已经向Heroku发送了一个pull请求,但是我不知道他们是否或什么时候会回应。 幸运的是,使用自定义的buildpack有一个不是很好的文档logging方法,可以让你解决这个问题。 我已经分叉heroku的nodejs buildpack并解决了这个问题 – 可在这里:

https://github.com/chrisleishman/heroku-buildpack-nodejs/tree/git_fix

要使用它,你最好创build自己的https://github.com/heroku/heroku-buildpack-nodejs的github fork,然后合并到我的chrisleishman/git_fix分支中。 例如(分叉后):

 git clone git@github.com:@YOUR-GITHUB-NAME@/heroku-buildpack-nodejs.git cd heroku-buildpack-nodejs git remote add chrisleishman git://github.com/chrisleishman/heroku-buildpack-nodejs.git git fetch chrisleishman git merge chrisleishman/git_fix git push 

然后,您可以将BUILDPACK_URLconfigurationvariables添加到您的heroku应用程序。 例如

 heroku config:add BUILDPACK_URL="git://github.com/@YOUR-GITHUB-NAME@/heroku-buildpack-nodejs.git 

接下来推向heroku应该使用定制buildpack,包含修复。

仅供参考,如果它在GitHub上,您可以指定username/repository和npm将完成剩下的工作。

 { "name": "application-name" , "version": "0.0.1" , "private": true , "dependencies": { "coffee-script": "1.1.3" , "express": "2.5.0" , "less": "1.1.5" , "jade": "0.17.0" , "connect-redis": "1.2.0" , "hiredis": "0.1.13" , "redis": "0.7.1" , "bcrypt": "0.4.1" , "promised-io": "0.3.0" , "jugglingdb": "juggy/jugglingdb" , "nodemailer": "0.2.3" } } 

另外

指定( git / git+ssh / git+http / git+https )之一://user@host/repo.giturl

完整logging

我不知道这个软件包,但我有其他人使用如下语法。 在heroku上,使用对tar.gz的http引用

的package.json:

 { "name": "application-name" , "version": "0.0.1" , "private": true , "dependencies": { "coffee-script": "1.1.3" , "express": "2.5.0" , "less": "1.1.5" , "jade": "0.17.0" , "connect-redis": "1.2.0" , "hiredis": "0.1.13" , "redis": "0.7.1" , "bcrypt": "0.4.1" , "promised-io": "0.3.0" , "jugglingdb": "https://github.com/juggy/jugglingdb/tarball/master" , "nodemailer": "0.2.3" } } 

请注意,您可以指定commit-ish以"user/foo-project#commit-ish"的formsselect要安装的提交/分支/ …,请参阅文档 。

一个例子:

 "dependencies": { "express": "visionmedia/express#some-branch", "mocha": "visionmedia/mocha#4727d357ea" } 

不知道这是同一个问题在这个date,但我遇到了相同的错误信息,我发现我能够解决它通过明确指定节点和npm的版本每页:

https://devcenter.heroku.com/articles/nodejs-versions

我有一个类似的问题,除了我提到一个私人的git回购。 我的解决scheme是为以下内容添加一个postinstall脚本:

 { "postinstall": "npm update && npm install package-name" } 

更新和安装使npm更新到最新的私人回购。 ( https://github.com/npm/npm/issues/1727

如果有人用npm 5+(其中package-lock.json是一件事情)挣扎着,请确保通过命令行安装包。

npm i my_package --save https://github.com/username/repo/archive/v6.5.2.tar.gz

截至NPM 5.0.3简单地将其添加到package.json和运行npm i不会更新package-lock.json (grrr)。