我正在尝试安装一个最近从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包也是私有的。
发布于 2014-09-13 13:29:36
npm install git+ssh://git@bitbucket.org/{user}/{repository}.git
发布于 2017-05-10 02:20:50
npm install bitbucket:<bitbucketname>/<bitbucketrepo>
发布于 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日起,add
的Yarn 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
连接起来
https://stackoverflow.com/questions/24989694
复制相似问题