Does npm always pull from the master branch if a branch isn't specified in the dependency? What if I have another branch, say develop
and I tag the commit there? I know npm will update from a specific branch, if written like
"private-repo": "git+ssh://[email protected]:myaccount/myprivate.git#develop"
but what if I want to pull a specific tag from that branch? Because just specifying the tag, like
"private-repo": "git+ssh://[email protected]:myaccount/myprivate.git#v1.0.1"
did not work (the master
branch does not have the tagged commit. Just the develop
branch has it). I got a fatal: ambiguous argument 'v1.0.1': unknown revision or path not in the working tree.
which leads me to the thought that it tries to find the specified tag in a branch that does not have it (which must be the master
branch, since I've got only these 2 branches).
So, is there a way to specify both the branch and the git-tag from which to update?
If you want to restrict access and visibility for a public package you own, you can make the package private. When you make a package private, its access will be updated immediately and it will be removed from the website within a few minutes of the change.
Using NPM: AUTH_TOKEN can be generated by going to Github Profile > Settings > Developer settings >Personal access token: set read/write package, read package checked and click save. Copy the token as you will not have access to it later. You can read about . npmrc options by clicking here.
Open package. json , to to the "devDependencies" or "dependencies" key and add your package in the following format: "package-name": "username/repo#branch-name", And then install the package with npm install or yarn .
For npm install specific version, use npm install [package-name]@[version-number]. Use npm view [package-name] version to know the specific latest version of a package available on the npm registry. Use npm list [package-name] to know the specific latest version of an installed package.
There's not any direct link between branches & tags. In a way, tags are just branches that do not move when commiting.
You should be able to checkout (or npm install) any branche or any tag (or any commit ref) you refer to.
It looks like v1.0.1
is not a tag (neither a branch) of your repository. If you want a semver selection of the right version, you have to prefix it with semver:
.
Take a look at npm official documentation about package dependencies. It explains all the way to use git repositories as package source :
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
git+ssh://[email protected]:npm/cli.git#v1.0.27
git+ssh://[email protected]:npm/cli#semver:^5.0
git+https://[email protected]/npm/cli.git
git://github.com/npm/cli.git#v1.0.27
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With