2015-10-17 120 views

回答

38

GitHub的是保持每一個namespace公關在原始回購,所以這也適用:

npm install <user>/<repo>#pull/<id>/head 

NOTE: It doesn't seeem to be working with NPM v. 5. See the comment below .

例如:

npm i --save-dev json-schema-faker/json-schema-faker#pull/129/head 

yarn

yarn add <user>/<repo>#<id>/head 

例如:

yarn add json-schema-faker/json-schema-faker#129/head 

注意,在紗線情況下,存在在沒有pull/段包標識tifier。

如果您需要自動刪除從其中發起PR的安裝或repo /分支,這可能會有所幫助。另請參閱GitHub上的Modifying an inactive pull request locally

+0

這有效,但:我如何安裝多個拉請求(併合並它們)? – Munchkin

+2

@Munchkin我不認爲這是你會用NPM本身做的事情。也許叉存儲庫,合併公關的叉子,並從那裏安裝? –

+2

紗線(或Github了?)似乎不支持拉標籤。所以對於上面的例子來說:json-schema-faker/json-schema-faker#129/head。對於某些PR,還有一個「合併」(而不是「頭」)後綴,但我不知道這意味着什麼。 –

14

How to install NodeJS package from GitHub directly?」提到你可以指定一個分支。

所以,如果你知道從哪個公關來源於回購和分支,你可以做:

npm install git+https://github.com/user/repo.git#branch 

Worth saying that you might need to escape the # to use a specific branch from the shell, i.e.:

npm install git+https://github.com/user/repo.git\#branch 

Note that repository you want to install must be a npm module, it must contain a package.json file or else you will get this error:

Error: ENOENT, open 'tmp.tgz-unpack/package.json'.