git - npm install 在 Linux 上的 HTTP 身份验证失败
问题描述
我正在尝试npm install git+https://bitbucket.org/User/Repository
在 Linux Raspbian 8.0 上运行。但是,我收到此错误:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://bitbucket.org/User/Repository.git
npm ERR!
npm ERR! remote: Invalid username or password
npm ERR! fatal: Authentication failed for 'https://bitbucket.org/User/Repository.git/'
npm ERR!
npm ERR! exited with error code: 128
我的 Bitbucket 用户名和应用程序密码应该在全局和目录 git 配置中都可用:
git config user.name "Username"
git config user.password "Password"
git config --global user.name "Username"
git config --global user.password "Password"
因此,应该可以使用正确的用户名和密码npm
,但似乎没有使用它们。
另外,为免生疑问,我已经通过直接使用它们来验证用户名和密码是否正确git
。
解决此问题的任何帮助将不胜感激!
编辑 感谢 Matthieu Moy 在评论中指出我使用的配置值实际上对 Git 没有任何特殊含义。
根据文档,用户名和密码组合可以存储在~/.git-credentials
. 我已经这样做了,形式为https://Username:Password@bitbucket.org
。但是,与上述相同的错误仍然存在。我已验证用户名和应用程序密码是否正确。Git 似乎根本没有使用它们。
解决方案
似乎明确指定解决问题的.git-credentials
路径git
。我使用以下命令这样做:
git config --global credential.helper 'store --file=/path/to/.git-credentials'
推荐阅读
- unit-testing - 无法从测试用例访问房间数据库 - Android
- php - 在 php passthru 中使用变量
- kotlin - 使用 Klaxon 使用动态键解析地图
- spring - 负载平衡器和断路器
- javascript - IE 11 中对 blob 的支持的画布
- angular - 如何防止在.net Angular项目中检查生成的dist文件夹?或者不在项目中生成?
- kendo-ui - 如何搜索展开的项目?
- css - 如何在我的 Woocommerce 网站上解决此行内块对齐问题?
- google-apps-script - 无法使用 Google Apps 脚本将图像添加到表单中
- r - 将行排序为非字母自定义顺序