3

I have a fork in github. I am able to install target like this in npm

"my-fork-of-a-package": "github:my-profile/my-fork-of-a-package#branch"

in package.json. However I am unable to target a tag of the branch or a version number.

I'm looking for a some kind of @version or @tag or @commitHash syntax. Something kinda like this - except for that this doesn't work. '"my-fork-of-a-package": "github:my-profile/my-fork-of-a-package#branch@version"

Tarek Adam
  • 3,387
  • 3
  • 27
  • 52

2 Answers2

4

You can do this by using the #semver:<semver> notation like so:

"my-fork-of-a-package": "github:my-profile/my-fork-of-a-package#semver:v1.0.27"
tenfishsticks
  • 452
  • 5
  • 13
3

Your question is tricky for a potential answer because generally, a branch implies the version number.

As per docs:

npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]:

Install the package at https://gitlab.com/gitlabname/gitlabrepo by attempting to clone it using git.

If # is provided, it will be used to clone exactly that commit. If the commit-ish has the format #semver:, can be any valid semver range or exact version

https://docs.npmjs.com/cli/install

Why don't you simply consolidate on only one level (branch1-v1, branch1-v2,branch2-v1...)?

You can effectively call a #branch, so i think it would be safe for you to rename & update your data structure to be 1 big pool with specific names.

That way, you'll be able to call the specific package/git through #branch1{your-own-separator}version-X.X

TL;DR: Add tags in name, will look messy but that's why search/indexes exist.