Heroku上的npm和Node使用Git依赖关系 [英] Use Git dependencies with npm and Node on Heroku

查看:90
本文介绍了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接收推送
----->获取自定义构建包... done
-----> Node.js应用检测到
----->获取Node.js二进制文件
----->供应节点0.4.7
----->使用npm 1.0.105安装依赖关系
npm ERR! git checkout master fatal:不是git仓库:'。'
npm ERR!错误:`gitcheckoutmaster`失败,出现128
npm ERR!在ChildProcess。< anonymous> (/tmp/node-npm-Jb2d/lib/utils/exec.js:49:20)
npm ERR!在ChildProcess.emit(events.js:67:17)
npm ERR!在ChildProcess.onexit(child_process.js:192:12)
npm ERR!报告此*整个*日志:
npm ERR! < HTTP://github.com/isaacs/npm/issues>
npm ERR!或通过电子邮件发送至:
npm ERR! < npm-@googlegroups.com>
npm ERR!
npm ERR!系统Linux 2.6.32-316-ec2
npm ERR!命令/ tmp / node-node-C3jD / bin / node/tmp/node-npm-Jb2d/cli.jsinstall
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:不是git仓库:'。'
npm ERR!
npm ERR!附加的日志记录细节可以在以下位置找到:
npm ERR! /tmp/build_2yzg7lk83o5m9/npm-debug.log
npm不行
!无法安装npm
的依赖关系! Heroku推送被拒绝,无法编译Node.js应用程序

另外,我似乎找不到方法在/ tmp中访问该日志文件。



任何人都可以在Heroku上部署Git依赖项(在Ruby上工作正常:P)? b $ b

解决方案

问题出在他们的nodejs buildpack中。我已经向Heroku发送了一个修正请求,但我不知道他们是否或何时会回复。幸运的是,使用自定义的buildpack有一个不是很好的文档记录方法,它可以让你解决这个问题。我已经分叉了heroku的nodejs buildpack并解决了这个问题 - 这里有:

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



要使用此功能,最好创建自己的 https://github.com/heroku/heroku-buildpack-nodejs 的github分支和然后在我的 chrisleishman / git_fix 分支中进行合并。例如。 (分叉后):

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

然后,您可以添加 BUILDPACK_URL 配置变量到你的heroku应用程序。例如

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

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

I have this package.json file:

{
    "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"
  }
}

and I want to deploy to Heroku. It works fine locally with npm version 1.0.105, but it chokes on Heroku (I updated the npm there to 1.0.105 as well):

   -----> 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 

Also, I do not seem to find a way to get access to that log file in /tmp.

As anyone succeed deploying a Git dependency on Heroku (works fine on ruby side :P) ?

解决方案

The problem is in their nodejs buildpack. I've sent a pull request to Heroku with a fix, but I have no idea if or when they'll respond. Fortunately, there's a not-very-well documented method for using a custom buildpack, which will allow you to work around the issue. I've forked heroku's nodejs buildpack and fixed the problem - available here:

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

To use this, you're best creating your own github fork of https://github.com/heroku/heroku-buildpack-nodejs and then merging in my chrisleishman/git_fix branch. E.g. (after forking):

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

You can then add the BUILDPACK_URL config variable to your heroku app. E.g.

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

The next push to heroku should then use the custom buildpack, containing the fix.

这篇关于Heroku上的npm和Node使用Git依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆