4

Is it possible some how to get update behaviour for git dependencies a like for NPM packages?

So I have git dependency:

"dependencies": {
  "my-module": "github:me/my-module"
}

And want it be updated each time I do npm install, adding revision hash is solution but requires more work to track and update in package.json each time package is update on Github.

There are also git tags (which also can be set using npm version command - it creates commit with tag v1.2.3. Is there is way to use these tags in dependencies in package.json?

git tag on repo gives me:

v1.0.1  
v1.0.0  

If I try to add in package.json after module name version like: #1.0.0 or #v1.0.1

```
"dependencies": {
"my-module": "github:me/my-module#1.0.1"
}
```

Install fails with error:

Command failed: git -c core.longpaths=true rev-list -n1 1.0.0
fatal: ambiguous argument '1.0.0': unknown revision or path not in the
ree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'


If you need help, you may report this error at:
    <https://github.com/npm/npm/issues>
1
  • If git tag gives you values like v1.0.0 etc, then you need to use that exact value. Using 1.0.0 will fail. Commented Feb 6, 2016 at 9:25

3 Answers 3

4

This can be done like this

"my-module": "git+https://github.com/user/repo.git#v1.2.3"

Sign up to request clarification or add additional context in comments.

3 Comments

This does work, have you definitely pushed your tags up to github? git push --follow-tags Is your tag name correct?
Thanks right, But there is no poisibility to have something like #^v1.0.0 and have utomatic updates for patches/minor versions?
Yep no semver support unfortunately
1

If you are looking for semver support for git dependencies, I am afraid you are out of luck.

When installing git dependencies, npm allows you to specify one of the following to control what particular commit you whish to install as a dependency:

  • commit (full sha1 string of the commit)
  • commit (short commit string)
  • branch
  • tag

The format is defined as follows:

package.json:

{
  "dependencies": {
    "some-dep": "username/reponame#commit-ish"
  }
}

Where commit-ish is one of the items listed above.

Attempting to use one of the semver modifiers when specifying commit-ish will fail, ie. #~1.2.3 is not a valid commit-ish. See the docs for yourself.

Comments

0

I tried using git+ssh but didn't work. Finally this worked for me for repo in bitbucket

"my-module": "git+https://bitbucket.org/repos/myrepo/#0.1.0"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.