繁体   English   中英

npm install在Linux上的HTTP身份验证失败

[英]npm install fails HTTP authentication on Linux

我正在尝试在Linux Raspbian 8.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 configs中都可用:

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-credentialsgit的路径可以解决此问题。 我使用以下命令执行此操作

git config --global credential.helper 'store --file=/path/to/.git-credentials'

我认为bitbucket不想让您从不受信任的来源进行连接。 为此,您将需要一个受信任的密钥。 该问题已得到解决: 如何解决npm install中的身份验证错误?

-这是该人告诉您尝试的内容-

如果可以,您应该:

@libzz,我无法评论已接受的答案(我的声誉不高),但要回答您的问题:如果您不想存储凭据,则可以使用“ cache ”作为凭据。helper设置。

git config --global credential.helper cache

如果您向git提供用户名/密码,它将把它们缓存15分钟。

因此,在npm install之前,您可以在npm install上执行git pull ,以使git提示并临时缓存您的凭据。 npm install git将能够使用您的缓存凭据从同一服务器克隆。

这样就无需使用凭据将文件存储为纯文本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM