Git repository to a dependency in package.json

断了今生、忘了曾经 提交于 2020-06-28 10:18:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!