5

I am having a git repository and want to use this repository as a dependency in package.json file of some other project so that it can be downloaded as we run npm command. can anyone help me out?

Vivek Gupta
  • 61
  • 1
  • 4

3 Answers3

6

Try this.

"dependencies": {
    "<repo>": "<user>/<repo>#<branch>",
}

Example:

"dependencies": {
   "botkit": "jonchurch/botkit#master",
}

Reference is here!

Rafael Pizao
  • 742
  • 8
  • 21
1

From the NPM docs:

Git URLs as Dependencies

git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish
Bjørn Sørensen
  • 901
  • 1
  • 6
  • 14
0

Try below format in your package.json:

"dependencies" : {
  "projectName" : "git://github.com/user/project.git"
}
Deepak Biswal
  • 4,280
  • 2
  • 20
  • 37
  • Could not install /tmp/npm-14485-f3914b67/git-cache-5670ae183f1b/efb22ee81642ce5f041c7e9f0e793c5618f569cf this error is coming – Vivek Gupta Mar 18 '16 at 08:39