问题
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?
回答1:
Try this.
"dependencies": {
"<repo>": "<user>/<repo>#<branch>",
}
Example:
"dependencies": {
"botkit": "jonchurch/botkit#master",
}
Reference is here!
回答2:
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
回答3:
Try below format in your package.json
:
"dependencies" : {
"projectName" : "git://github.com/user/project.git"
}
来源:https://stackoverflow.com/questions/36078409/git-repository-to-a-dependency-in-package-json