从gitlab私有存储库安装npm模块 [英] Install npm module from gitlab private repository

查看:742
本文介绍了从gitlab私有存储库安装npm模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为我们的私人项目使用 GitLab 。有一些来自github的分叉库,我们想以npm模块的形式安装。



npm install git://github.com/FredyC/grunt-stylus- sprite.git



...也可以正常工作,但对GitLab也是如此,只是更改域会导致出现此错误。

  npm WARN`git config --get remote.origin.url`返回错误结果(git://git.domain.com/library /grunt-stylus-sprite.git)
npm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git克隆到裸仓库'D:\ users \Fredy\AppData\Roaming\\\
pm-cache\_git-remotes \git-git-domain-com-library-grunt-stylus-sprite-git-6f33bc59'...
npm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git致命:无法连接到git.domain.com:
npm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git git.domain.com [0:77.93.195.214]:errno =没有错误
npm ERR!错误:命令失败:克隆到裸存储库'D:\ users \Fredy\App
Data\Roaming\\\
pm-cache\__git-remotes\git-git-domain-com-library -grunt-stylus-spr
ite-git-6f33bc59'...
npm ERR!致命:无法连接到git.domain.com:
npm ERR! git.domain.com [0:xx.xx.xx.xx]:errno =没有错误

从GitLab的Web界面,我有这个URL
git@git.domain.com:library / grunt-stylus-sprite.git 。在 npm install 中运行它,它会尝试从npm注册表中安装 git 模块。



然而,使用URL: git+ssh@git.domain.com:library / grunt-stylus-sprite.git 突然要求输入密码。我的SSH密钥不包括密码,所以我认为它不能加载该密钥。也许有一些我错过的配置? Key位于主目录中的标准位置,名称id_rsa



我在Windows 7上x64。
$ b

UPDATE

由于NPM v3内置了对GitLab和其他来源(BitBucket,Gist),从中可以安装软件包。不幸的是,它只适用于公共网站,因此它与此并不完全相关,但有些可能会发现它有用。



npm install gitlab:< gitlabname> ; /< gitlabrepo> [#< commit-ish>]



查阅文档:https://docs.npmjs.com/cli/install

解决方案

我使用GitLab的私人实例也遇到同样的问题。从现有答案中,您可以使用私人托管的存储库以下内容:

  git + ssh:// git @ git.mydomain.com:Username / Repository#{branch | tag} 

  git + ssh://git@git.mydomain.com/Username/Repository# {branch | tag} 

更新



从npm文档 https://docs.npmjs.com/files/package.json 。 NPM处理这两种情况,但您连接的git服务可能不会。


We are using GitLab for our private project. There are some forked libraries from github, that we want to install as npm module. Installing that module directly from npm is ok and for example this:

npm install git://github.com/FredyC/grunt-stylus-sprite.git

...works correctly too, but doing the same for GitLab, just changing domain gets me this error.

npm WARN `git config --get remote.origin.url` returned wrong result (git://git.domain.com/library/grunt-stylus-sprite.git)
npm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git Cloning into bare repository 'D:\users\Fredy\AppData\Roaming\npm-cache\_git-remotes\git-git-domain-com-library-grunt-stylus-sprite-git-6f33bc59'...
npm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git fatal:unable to connect to git.domain.com:
npm ERR! git clone git://git.domain.com/library/grunt-stylus-sprite.git git.domain.com[0: 77.93.195.214]: errno=No error
npm ERR! Error: Command failed: Cloning into bare repository 'D:\users\Fredy\App
Data\Roaming\npm-cache\_git-remotes\git-git-domain-com-library-grunt-stylus-spr
ite-git-6f33bc59'...
npm ERR! fatal: unable to connect to git.domain.com:
npm ERR! git.domain.com[0: xx.xx.xx.xx]: errno=No error

From the web interface of GitLab, I have this URL git@git.domain.com:library/grunt-stylus-sprite.git. Running this against npm install it tries to install git module from npm registry.

However using URL: git+ssh@git.domain.com:library/grunt-stylus-sprite.git is suddenly asking me for the password. My SSH key doesn't include passphrase, so I assume it wasn't able to load that key. Maybe there is some configuration for that I have missed ? Key is located at standard location in my home directory with the name "id_rsa".

I am on Windows 7 x64.

UPDATE

Since NPM v3 there is built-in support for GitLab and other sources (BitBucket, Gist), from where you can install packages. Unfortunately it works only for public ones so it's not exactly related to this, but some might find it useful.

npm install gitlab:<gitlabname>/<gitlabrepo>[#<commit-ish>]

Check out documentation: https://docs.npmjs.com/cli/install

解决方案

I had the same issue using a private instance of GitLab. Taking from the existing answers you're able to use the privately hosted repositories with the following;

git+ssh://git@git.mydomain.com:Username/Repository#{branch|tag}

or

git+ssh://git@git.mydomain.com/Username/Repository#{branch|tag}

Update

Add alternative in comments and from npm documentation https://docs.npmjs.com/files/package.json. NPM handles both cases but the git service you're connecting to may not.

这篇关于从gitlab私有存储库安装npm模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆