17

職場では HTTP プロキシの背後にあり、git プロトコル (ポート 9418) は拒否されています。私のプロジェクトには NPM 依存関係があり、これらの依存関係の一部には git プロトコルを使用する依存関係があります。たとえば、次のようになります。

私の中でpackage.json

"dependencies": {
    "jsdoc3" : "git+https://github.com/jsdoc3/jsdoc.git"
}

およびpackage.jsonjsdoc3の:

"dependencies": {
    "crypto-browserify": "git://github.com/dominictarr/crypto-browserify.git#95c5d505",
    "github-flavored-markdown": "git://github.com/hegemonic/github-flavored-markdown.git"
}

これらの依存関係を取得するにはどうすればよいですかgit+https://、プロトコルの代わりにgit://プロトコルを使用するように NPM に指示する方法、または git プロトコルを使用できるようにする方法は?

簡単にするために、私は Windows で (Linux では SSH トンネルを作成する方が簡単です)、GIT-Bash を使用しています。

ありがとう

4

6 に答える 6

5

最後に、汚い解決策を見つけましたが、それはうまくいきます。gitプロトコルをプロトコルに置き換えるためにNPMのコードを修正しましたhttp(オープンソースのおかげです)

npm v1.1.69で、ファイルnpm/lib/cache.jsに、関数に次の行を追加しましたaddRemoteGit

 // ssh paths that are scp-style urls don't need the ssh://
 if (parsed.pathname.match(/^\/?:/)) {
   u = u.replace(/^ssh:\/\//, "")
 }

 //begin trick
 if(/^git:/.test(u)){
     u = u.replace(/^git/, 'https');
 }
 //end trick

 log.verbose("addRemoteGit", [u, co])
于 2013-02-19T11:03:40.090 に答える
1

依存 URL でgit+https://またはを指定することが可能 ですgit+http://

から次のpackage.jsonを取得しました

{
  "name": "Sample package",
  "description": "Pacake for a Stackoverflow question",
  "author": "rk <rk@example.sampletld>",
  "dependencies": {
    "crypto-browserify": "git+https://github.com/dominictarr/crypto-browserify.git#95c5d505",
    "github-flavored-markdown": "git+https://github.com/hegemonic/github-flavored-markdown.git"
  },
  "engine": "node 0.4.1"
}

私はそれから走っnpm installnode_modules、次のものが含まれていました

C:\Users\myself\node\node_modules>dir
 Volume in drive C is WINDOWS
 Volume Serial Number is 6E7A-96BE

 Directory of C:\Users\myself\node\node_modules

18/02/2013  13:57    <DIR>          .
18/02/2013  13:57    <DIR>          ..
18/02/2013  13:58    <DIR>          .bin
18/02/2013  13:57    <DIR>          crypto-browserify
18/02/2013  13:56    <DIR>          express
18/02/2013  13:57    <DIR>          github-flavored-markdown
18/02/2013  13:56    <DIR>          optimist
               0 File(s)              0 bytes
               7 Dir(s)  31,641,919,488 bytes free

C:\Users\myself\node\node_modules>

git+http と git+https の両方のプロトコルでこれを試してみましたが、どちらも機能しましたが、裸の http は機能せず、エラーが発生しました。

于 2013-02-18T14:11:35.763 に答える
1

@Nowresの提案に加えて、それを機能させるために次のことをしなければなりませんでした

git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://
于 2015-03-23T14:32:56.433 に答える