首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法从bitbucket存储库安装npm

无法从bitbucket存储库安装npm
EN

Stack Overflow用户
提问于 2014-07-28 14:39:56
回答 7查看 36.8K关注 0票数 37

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

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

最终结果是

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

(请注意url中的包),并显示此错误:

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

(注意@后面的' )

我尝试转义@,将repo name用引号括起来,但总是得到相同的结果。

对于github,我们使用格式为git://github.com/owner/repo#v.v.v的urls,这很好用!但是如果我对bitbucket使用相同的语法,npm就会挂起,什么也不做。

有什么想法吗?

附注:密钥、访问权限等等都是正确的。我可以为这些repos做贡献,用git克隆它们,但不能用npm install。安装良好的Github包也是私有的。

EN

回答 7

Stack Overflow用户

发布于 2014-09-13 13:29:36

npm install git+ssh://git@bitbucket.org/{user}/{repository}.git
票数 73
EN

Stack Overflow用户

发布于 2017-05-10 02:20:50

npm install bitbucket:<bitbucketname>/<bitbucketrepo>
票数 18
EN

Stack Overflow用户

发布于 2019-03-01 00:58:59

声明:正如Eric Uldall所说:这种方法很简单,但它缺乏安全性。现在,您已经向存储库提交了纯文本形式的密码。这就是我最近的工作方式,但不推荐。

直接从install命令的npm Documentation

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

示例:

$ npm install bitbucket:mybitbucketuser/myproject

从2019年2月28日起,addYarn documentation不支持git存储库。

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

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

然后,您可以将依赖项添加到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

别忘了替换:

将您的username

  • password:与您的应用程序password

  • repo-owner:进行
  • username:,将repo
  • repo:的所有者与模块的存储库名称

连接起来

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24989694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档