【问题标题】:npm install remote repository: fetch failed with status code 401npm install remote repository:获取失败,状态码 401
【发布时间】:2019-06-24 19:09:15
【问题描述】:

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

npm/git 不提示输入 gitlab 凭据

我试过这两个:

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

他们都没有改变任何东西

命令:

$ 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 中添加凭据不起作用:相同的输出。

【问题讨论】:

    标签: git npm gitlab


    【解决方案1】:

    我建议你使用SSH 协议而不是http。您将需要生成SSH keys。然后你就可以安装了:

    npm install git@gitlab.blabla.com:bla
    

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

    npm install http://username:password@gitlab.blabla.com/bla
    

    【讨论】:

    • 很遗憾我不能,因为这个存储库没有设置为 ssh 身份验证
    • 在 url 中添加凭据对我不起作用,相同的输出
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 1970-01-01
    • 2018-04-22
    • 2015-02-10
    • 2016-01-22
    • 2021-05-18
    • 1970-01-01
    相关资源
    最近更新 更多