使用https协议在package.json中使用私有git repo进行npm安装的权限错误

时间:2015-09-03 08:05:56

标签: git npm

我在使用https

的依赖项中使用package.json中的这个url
<private repo>:"git+https://<token>:x-oauth-basic@github.com/<org>/<private repo>"

我也试过这个

<private repo>:"git+https://<token>:x-oauth-basic@github.com/<org>/<private repo>.git"

最后只添加.git

我知道令牌是有效的Becz

当我使用下面的命令在终端正常工作时克隆这个回购

git clone https://<token>:x-oauth-basic@github.com/<org>/<private repo>.git

所以即使我没有使用ssh protocole

,我也会收到这样的错误
 npm ERR! Permission denied (publickey).
 npm ERR! fatal: Could not read from remote repository.
 npm ERR!
 npm ERR! Please make sure you have the correct access rights
 npm ERR! and the repository exists.

我通过选择范围read:org,write:org

创建了此令牌

1 个答案:

答案 0 :(得分:2)

检查您的NPM版本(npm -v)。 NPM 2.7.4(可能是2.7.5)中存在一个错误,导致私有回购的克隆失败。

请参阅:https://github.com/nodejs/node/issues/1323

今天我遇到了安装2.7.4的问题。我更新了最新的nodejs,它降低了NPM 2.11.3,我能够通过git + https获得一个私人仓库,并且令牌很好。