问题
As discussed here the way we identify a PR from which to install a Node.js package is different when using Yarn client and different when using original NPM command line client, e.g.:
npm install json-schema-faker/json-schema-faker#pull/129/head
and
yarn add json-schema-faker/json-schema-faker#129/head
Note that in Yarn's case there is no pull/
segment in the package identifier.
Trying it other way around results in the following:
$ npm install json-schema-faker/json-schema-faker#129/head
npm ERR! git rev-list -n1 129/head: fatal: ambiguous argument '129/head': unknown revision or path not in the working tree.
npm ERR! git rev-list -n1 129/head: Use '--' to separate paths from revisions, like this:
npm ERR! git rev-list -n1 129/head: 'git <command> [<revision>...] -- [<file>...]'
npm ERR! git rev-list -n1 129/head:
npm ERR! git rev-list -n1 129/head: fatal: ambiguous argument '129/head': unknown revision or path not in the working tree.
npm ERR! git rev-list -n1 129/head: Use '--' to separate paths from revisions, like this:
npm ERR! git rev-list -n1 129/head: 'git <command> [<revision>...] -- [<file>...]'
npm ERR! git rev-list -n1 129/head:
npm ERR! git rev-list -n1 129/head: fatal: ambiguous argument '129/head': unknown revision or path not in the working tree.
npm ERR! git rev-list -n1 129/head: Use '--' to separate paths from revisions, like this:
npm ERR! git rev-list -n1 129/head: 'git <command> [<revision>...] -- [<file>...]'
npm ERR! git rev-list -n1 129/head:
npm ERR! Darwin 15.6.0
npm ERR! argv "$HOME/.nvm/versions/node/v7.7.3/bin/node" "$HOME/.nvm/versions/node/v7.7.3/bin/npm" "install" "json-schema-faker/json-schema-faker#129/head"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! code 128
npm ERR! Command failed: git rev-list -n1 129/head
npm ERR! fatal: ambiguous argument '129/head': unknown revision or path not in the working tree.
npm ERR! Use '--' to separate paths from revisions, like this:
npm ERR! 'git <command> [<revision>...] -- [<file>...]'
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! $HOME/Projects/playground/npm-debug.log
or
$ yarn add json-schema-faker/json-schema-faker#pull/129/head
yarn add v0.21.3
[1/4] 🔍 Resolving packages...
error Couldn't find match for "pull/129/head" in "develop,greenkeeper/browserify-14.0.0,greenkeeper/browserify-14.1.0,greenkeeper/codecov-2.0.1,greenkeeper/codecov-2.0.2,greenkeeper/codecov-2.1.0,greenkeeper/eslint-3.13.0,greenkeeper/eslint-3.13.1,greenkeeper/eslint-3.14.0,greenkeeper/eslint-3.14.1,greenkeeper/eslint-3.15.0,greenkeeper/eslint-3.16.0,greenkeeper/eslint-3.17.0,greenkeeper/eslint-3.17.1,greenkeeper/eslint-3.18.0,greenkeeper/faker-4.0.0,greenkeeper/faker-4.1.0,greenkeeper/fs-extra-2.0.0,greenkeeper/fs-extra-2.1.0,greenkeeper/fs-extra-2.1.1,greenkeeper/fs-extra-2.1.2,greenkeeper/tslint-4.1.0,greenkeeper/tslint-4.1.1,greenkeeper/tslint-4.2.0,greenkeeper/tslint-4.3.0,greenkeeper/tslint-4.3.1,greenkeeper/tslint-4.4.0,greenkeeper/tslint-4.4.1,greenkeeper/tslint-4.4.2,greenkeeper/tslint-4.5.0,greenkeeper/tslint-4.5.1,master,102/head,103/head,103/merge,104/head,104/merge,105/head,107/head,108/head,108/merge,109/head,110/head,112/head,119/head,119/merge,123/head,129/head,130/head,136/head,138/head,143/head,144/head,144/merge,146/head,147/head,149/head,151/head,156/head,159/head,16/head,161/head,162/head,165/head,166/head,167/head,168/head,17/head,173/head,177/head,178/head,182/head,183/head,184/head,185/head,186/head,187/head,189/head,19/head,190/head,191/head,192/head,196/head,197/head,20/head,200/head,201/head,202/head,207/head,208/head,209/head,21/head,214/head,214/merge,215/head,215/merge,216/head,216/merge,220/head,220/merge,228/head,23/head,235/head,235/merge,24/head,244/head,244/merge,246/head,246/merge,247/head,247/merge,248/head,248/merge,249/head,250/head,253/head,253/merge,254/head,255/head,255/merge,26/head,27/head,3/head,32/head,33/head,33/merge,36/head,37/head,38/head,39/head,40/head,47/head,48/head,49/head,50/head,51/head,51/merge,59/head,59/merge,60/head,61/head,61/merge,64/head,64/merge,65/head,75/head,78/head,78/merge,79/head,79/merge,8/head,8/merge,85/head,85/merge,86/head,87/head,87/merge,93/head,94/head,95/head,v0.1.0,v0.1.1,v0.1.10,v0.1.11,v0.1.12,v0.1.13,v0.1.2,v0.1.3,v0.1.4,v0.1.5,v0.1.6,v0.1.7,v0.1.8,v0.1.9,v0.2.0,v0.2.1,v0.2.10,v0.2.11,v0.2.12,v0.2.13,v0.2.14,v0.2.15,v0.2.16,v0.2.2,v0.2.3,v0.2.4,v0.2.5,v0.2.6,v0.2.7,v0.2.8,v0.2.9,v0.3.0,v0.3.1,v0.3.2,v0.3.3,v0.3.4,v0.3.5,v0.3.6,v0.3.7,v0.4.0,v0.4.1" for "https://github.com/json-schema-faker/json-schema-faker.git".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
What is the underlying (technical) reason for that?
来源:https://stackoverflow.com/questions/42999809/why-is-the-reference-for-a-package-to-be-installed-from-a-pull-request-different