Depend on a branch or tag using a git URL in a package.json? Depend on a branch or tag using a git URL in a package.json? git git

Depend on a branch or tag using a git URL in a package.json?


From the npm docs:

git://github.com/<user>/<project>.git#<branch>git://github.com/<user>/<project>.git#feature\/<branch>

As of NPM version 1.1.65, you can do this:

<user>/<project>#<branch>


per @dantheta's comment:

As of npm 1.1.65, Github URL can be more concise user/project. npmjs.org/doc/files/package.json.html You can attach the branch like user/project#branch

So

"babel-eslint": "babel/babel-eslint",

Or for tag v1.12.0 on jscs:

"jscs": "jscs-dev/node-jscs#v1.12.0",

Note, if you use npm --save, you'll get the longer git

From https://docs.npmjs.com/cli/v6/configuring-npm/package-json#git-urls-as-dependencies

Git URLs as Dependencies

Git urls are of the form:

git+ssh://git@github.com:npm/cli.git#v1.0.27git+ssh://git@github.com:npm/cli#semver:^5.0git+https://isaacs@github.com/npm/cli.git
git://github.com/npm/cli.git#v1.0.27

If #<commit-ish> is provided, it will be used to clone exactly that commit. If > the commit-ish has the format #semver:<semver>, <semver> can be anyvalid semver range or exact version, and npm will look for any tags or refsmatching that range in the remote repository, much as it would for a registrydependency. If neither #<commit-ish> or #semver:<semver> is specified, thenmaster is used.

GitHub URLs

As of version 1.1.65, you can refer to GitHub urls as just "foo":"user/foo-project". Just as with git URLs, a commit-ish suffix can beincluded. For example:

{ "name": "foo", "version": "0.0.0", "dependencies": {   "express": "expressjs/express",   "mocha": "mochajs/mocha#4727d357ea",   "module": "user/repo#feature\/branch" }}```


If you want to use devel or feature branch, or you haven’t published a certain package to the NPM registry, or you can’t because it’s a private module, then you can point to a git:// URI instead of a version number in your package.json:

"dependencies": {   "public": "git://github.com/user/repo.git#ref",   "private": "git+ssh://git@github.com:user/repo.git#ref"}

The #ref portion is optional, and it can be a branch (like master), tag (like 0.0.1) or a partial or full commit id.