npm安装远程存储库:获取失败,状态码为401

时间:2019-01-31 10:36:09

标签: git npm gitlab

尝试安装远程软件包失败,状态码为401,

npm / git不会提示您输入gitlab凭据

我尝试了这两个:

git config --unset credential.helper
git config --global --unset credential.helper

他们都没有改变

cmd:

$ npm install http://gitlab.blabla.com/bla

npm ERR! fetch failed http://gitlab.blabla.com/bla
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 401
npm ERR! fetch failed http://gitlab.blabla.com/bla
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 401
npm ERR! fetch failed http://gitlab.blabla.com/bla
npm ERR! Linux 4.15.0-43-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "http://gitlab.blabla.com/bla"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2

npm ERR! fetch failed with status code 401
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/bla/test/npm-debug.log

我希望npm提示我提供远程访问凭据,但是什么也没有。

如何解决此提示问题?

编辑:SSH身份验证不是一个选项。

编辑2:在URL中添加凭据无效:相同的输出。

1 个答案:

答案 0 :(得分:0)

我建议您使用SSH协议而不是http。您将需要生成SSH keys。然后,您将能够安装:

npm install git@gitlab.blabla.com:bla

使用http的另一种方法是将凭据添加到URL:

npm install http://username:password@gitlab.blabla.com/bla
相关问题