2

we are working on node.js application and I consume my colleges package which is published to npm, now he create new Git branch (let's call it second) there is a way to somehow consume it in the package.json without publish it to npm ? ( I just want to test the new branch )

update I try something like

"git://github.mycompany.corp/vv/app.js.git#newbranch"

and its not working any idea ?

2 Answers 2

2

You can use a particular github branch in package json by adding dependency in below specified format:

git://github.com/<user>/<project>.git#<branch>
Sign up to request clarification or add additional context in comments.

1 Comment

This didn't work for me as is, but removing .git worked: git://github.com/<user>/<project>#<branch>
1

so one way is to take the clone of the whole project and Try these steps

1) Fetch all the branches

git fetch origin 

2) checkout to your second branch

git checkout <second branch name> like
git checkout second

3) now test the second branch

Other way could be to use git subModules to include the package as the submodule in your project Please refer this link:

https://git-scm.com/book/en/v2/Git-Tools-Submodules

git submodule add git://github.mycompany.corp/vv/app.js.git#newbranch

and then referrence package.json from there and test this.

4 Comments

THanks but I want to put it in the package.json and install it via npm install...
Yes please see the update, submodule may work for you as these all are alternates and the 1 answer which is described about referencing git branch in package.json please see this link: docs.npmjs.com/files/package.json#git-urls-as-dependencies
Thanks I also tried what you said and its not working, did I do something wrong here ? git://github.mycompany.corp/vv/app.js.git#a05d4b989dc234e26ee14fabb7f2597fc34a5301 , this is what I put in the package.json
the uuid is the commit sha .

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.