vas*_*shu 192 dependencies github node.js npm package.json
我正在尝试通过npm安装github私有存储库,其中包含其他私有github存储库作为依赖项.
尝试了很多方法和帖子,但没有一个工作.这是我正在做的事情:
npm install git+https://github.com/myusername/mygitrepository.git
Run Code Online (Sandbox Code Playgroud)
在package.json中就像:
"dependencies": {
"repository1name": "git+https://github.com/myusername/repository1.git",
"repository2name": "git+https://github.com/myusername/repository2.git"
}
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?
lek*_*eko 137
试试这个:
"dependencies" : {
"name1" : "git://github.com/user/project.git#commit-ish",
"name2" : "git://github.com/user/project.git#commit-ish"
}
Run Code Online (Sandbox Code Playgroud)
你也可以试试这个,其中visionmedia/express是name/repo:
"dependencies" : {
"express" : "visionmedia/express"
}
Run Code Online (Sandbox Code Playgroud)
或者(如果存在npm包模块):
"dependencies" : {
"name": "*"
}
Run Code Online (Sandbox Code Playgroud)
摘自NPM文档
vas*_*shu 83
以下在我需要的所有场景中都运行良好:
"dependencies": {
"GitRepo": "git+https://<token-from-github>:x-oauth-basic@github.com/<user>/<GitRepo>.git"
}
Run Code Online (Sandbox Code Playgroud)
mum*_*bot 67
对于那些来到这里公共目录的人,来自npm docs:https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
Git网址可以是以下形式:
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
Run Code Online (Sandbox Code Playgroud)
commit-ish可以是任何标记,sha或分支,可以作为git checkout的参数提供.默认值为master.
Mic*_*cik 55
接受的答案有效,但我不太喜欢将安全令牌粘贴到 package.json
我在其他地方找到了它,只需运行git-config联机帮助页中记录的这个一次性命令.
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf git@github.com:
Run Code Online (Sandbox Code Playgroud)
GITHUB_TOKEN
可以设置为environmnet变量或直接粘贴
然后我安装私有github repos像: npm install user/repo --save
也可以在Heroku中使用,只需将上面的git config ...
命令设置为heroku-prebuild
脚本package.json
并设置GITHUB_TOKEN
为Heroku配置变量.
Adr*_*ian 36
人们指出,有多种方法可以做到,但最短的版本是:
// from master
"depName": "user/repo",
// specific branch
"depName": "user/repo#branch",
// specific commit
"depName": "user/repo#commit",
Run Code Online (Sandbox Code Playgroud)
例如
"dependencies" : {
"hexo-renderer-marked": "amejiarosario/hexo-renderer-marked#patch-1",
"hexo-renderer-marked": "amejiarosario/hexo-renderer-marked#2249507",
"hexo-renderer-marked": "amejiarosario/hexo-renderer-marked",
}
Run Code Online (Sandbox Code Playgroud)
Ray*_*tor 25
"dependencies": {
"some-package": "github:github_username/some-package"
}
Run Code Online (Sandbox Code Playgroud)
要不就
"dependencies": {
"some-package": "github_username/some-package"
}
Run Code Online (Sandbox Code Playgroud)
https://docs.npmjs.com/files/package.json#github-urls
由于Git是curl
在后台使用的,因此可以使用~/.netrc
带有凭据的文件。对于GitHub,它看起来像这样:
machine github.com
login <github username>
password <password OR github access token>
Run Code Online (Sandbox Code Playgroud)
如果选择使用access tokens
,则可以通过以下方式生成:
设置->开发人员设置->个人访问令牌
如果您在自己的公司中使用Github Enterprise,这也应该起作用。只需将您的企业github网址放在machine
字段中即可。
这里有一个更详细的版本,说明如何在不发布package.json
文件的情况下使用 Github 令牌。
git config --global url."https://<TOKEN HERE>:x-oauth-basic@github.com/".insteadOf https://x-oauth-basic@github.com/
Run Code Online (Sandbox Code Playgroud)
npm install --loglevel verbose --save git+https://x-oauth-basic@github.com/<USERNAME HERE>/<REPOSITORY HERE>.git#v0.1.27
Run Code Online (Sandbox Code Playgroud)
如果访问 Github 失败,请尝试运行以下git ls-remote ...
命令npm install will print
归档时间: |
|
查看次数: |
161447 次 |
最近记录: |