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

前端 未结 5 1107
眼角桃花
眼角桃花 2020-11-29 15:49

Say I\'ve forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released.

How would I

5条回答
  •  粉色の甜心
    2020-11-29 16:48

    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/files/package.json#git-urls-as-dependencies

    Git URLs as Dependencies

    Git urls can be of the form:

    git://github.com/user/project.git#commit-ish git+ssh://user@hostname:project.git#commit-ish git+ssh://user@hostname/project.git#commit-ish git+http://user@hostname/project/blah.git#commit-ish git+https://user@hostname/project/blah.git#commit-ish

    The commit-ish can be any tag, sha, or branch which can be supplied as an argument to git checkout. The default is master.

    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 be included. For example:

    { "name": "foo",
    "version": "0.0.0",
    "dependencies": { "express": "visionmedia/express", "mocha": "visionmedia/mocha#4727d357ea" } }

提交回复
热议问题