无法从bitbucket repo安装npm

时间:2014-07-28 06:39:56

标签: node.js npm bitbucket

我正在尝试安装最近从github移动到bitbucket的私有包。

npm install git@bitbucket.org:owner/repo.git

最终以

结束
npm http GET https://registry.npmjs.org/git

(注意网址中的包),出现此错误:

  

npm ERR! notarget未找到兼容的版本:git@'bitbucket.org:flyvictor / fortune-secruity.git'

(请注意'之后的@

我试图逃避@,用引号包装repo名称,但总是得到相同的结果。

对于github,我们使用格式为git://github.com/owner/repo#v.v.v的网址,这样可以正常使用!但是如果我对bitbucket npm使用相同的语法,那就什么都不做。

有什么想法吗?

P.S。键,访问权限,所以一个是正确的。我可以为这些repos做贡献,用git克隆它们,但不能用npm install克隆它们。安装得好的Github软件包也是私有的。

7 个答案:

答案 0 :(得分:67)

npm install git+ssh://git@bitbucket.org/{user}/{repository}.git

答案 1 :(得分:9)

npm install bitbucket:<bitbucketname>/<bitbucketrepo>

答案 2 :(得分:3)

npm install ssh://git@bitbucket.org:{user}/{repository}.git

答案 3 :(得分:2)

我尝试了很多方法,但只有这对我有用:

npm install -s https://bitbucket.org/owner/repo-name/commits/tag/0.1.0

答案 4 :(得分:0)

因此,要从远程git存储库安装npm软件包,您需要确保

  • 您正在使用的计算机/虚拟机/容器中已安装git二进制文件
  • 您可以访问该存储库,并且我建议您对公共存储库的协议使用https而不是ssh,因为ssh协议要求您具有ssh凭据。

答案 5 :(得分:0)

npm Documentation直接开始执行install命令:

$ npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]

示例:

$ npm install bitbucket:mybitbucketuser/myproject

截止到2019年2月28日,add的{​​{3}}不支持git存储库。

上面的示例不适用于私有存储库,因为您将需要生成令牌才能使用它。怎么样?

登录到您的Bitbucket帐户,然后在用户设置下添加应用密码:

Yarn documentation

然后,您可以通过以下方式将依赖项添加到package.json中:

"dependencies": {
    "module": "git+https://<username>:<app-password>@bitbucket.org/<owner>/<repo>.git"
}

或在您的终端上输入:

npm install git+https://<username>:<app-password>@bitbucket.org/<repo-owner>/<repo>.git

别忘了更换:

  • 用户名:带有您的用户名
  • 密码:使用您的应用密码
  • 存储库所有者:与存储库的所有者
  • 回购:带有模块的存储库名称

答案 6 :(得分:0)

如果您的git服务器使用HTTP协议公开,并且您想使用以下格式安装特定分支,则使用

"your-module": "git+http://team-user:password@gitserver.com/git/my-module.git#branchName",