Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install private NPM module from specific branch and specific tag

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?

like image 287
Milkncookiez Avatar asked Jan 14 '16 15:01

Milkncookiez


People also ask

Can you make npm packages private?

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.

How do I install a private package on GitHub?

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.

How do I point a json package to a branch?

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 .

How do I install a specific version of npm?

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.


1 Answers

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
like image 72
mab Avatar answered Oct 22 '22 19:10

mab