我正在尝试在Linux Raspbian8.0上运行npm install git+https://bitbucket.org/User/Repository
。然而,我得到了这个错误:
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
中可以存储According to documentation、用户名和密码组合。我已经这样做了,以https://Username:Password@bitbucket.org
的形式。但是,与上面相同的错误仍然存在。我已验证用户名和应用程序密码是否正确。Git似乎根本没有使用它们。
发布于 2019-01-16 21:25:54
显式指定.git-credentials
到git
的路径似乎解决了这个问题。我用the following command做到了
git config --global credential.helper 'store --file=/path/to/.git-credentials'
发布于 2019-04-16 04:46:20
@libzz,我不能评论被接受的答案(我没有足够的声誉),但回答你的问题:如果你不想存储你的凭据,你可以使用'cache‘作为credentials.helper设置。
git config --global credential.helper cache
如果您提供用户名/密码给git,它将缓存它们15分钟。
因此,在您的npm install
之前,您可以对存储库执行类似git pull
的操作,以获得git提示并临时缓存您的凭据。在npm install
上,git将能够使用缓存的凭据从同一台服务器进行克隆。
这样就不再需要以纯文本格式存储凭据的文件。
发布于 2018-10-22 01:47:45
我认为bitbucket不希望你从一个不可信的来源进行连接。为此,您需要一个受信任的密钥。问题已经解决:How to resolve authentication error in npm install?
--这是这个人告诉你去尝试的--
如果可以,您应该:
https://stackoverflow.com/questions/52917787
复制相似问题