我试图通过npm安装github私有存储库,包括其他私有github存储库作为依赖。
我尝试了很多方法和帖子,但没有一个是有效的。这是我正在做的:
npm install git+https://github.com/myusername/mygitrepository.git
在包中。Json是这样的:
"dependencies": {
"repository1name": "git+https://github.com/myusername/repository1.git",
"repository2name": "git+https://github.com/myusername/repository2.git"
}
正确的做法是什么?
试试这个:
"dependencies" : {
"name1" : "git://github.com/user/project.git#commit-ish",
"name2" : "git://github.com/user/project.git#commit-ish"
}
你也可以试试这个,其中visionmedia/express是name/repo:
"dependencies" : {
"express" : "visionmedia/express"
}
或者(如果npm包模块存在):
"dependencies" : {
"name": "*"
}
摘自NPM文档
正如人们指出的,有多种方法可以做到这一点,但最短的版本是:
// from master
"depName": "user/repo",
// specific branch
"depName": "user/repo#branch",
// specific commit
"depName": "user/repo#commit",
// private repo
"depName": "git+https://[TOKEN]:x-oauth-basic@github.com/user/repo.git"
如。
"dependencies" : {
"hexo-renderer-marked": "amejiarosario/dsa.jsd#book",
"hexo-renderer-marked": "amejiarosario/dsa.js#8ea61ce",
"hexo-renderer-marked": "amejiarosario/dsa.js",
}