【问题标题】:npm install on windows fails with git respositoriesWindows 上的 npm 安装因 git 存储库而失败
【发布时间】:2021-11-28 09:50:49
【问题描述】:

每当我尝试使用 npm install 从加载到 git 存储库(在 Windows 上)的包中进行安装时,它都会失败:

2494 error An unknown git error occurred
2495 error command git --no-replace-objects ls-remote ssh://git@<SIT>/P_0001_PI/config-loader.git
2496 error <SITE>: Permission denied (publickey).
2496 error fatal: Could not read from remote repository.
2496 error
2496 error Please make sure you have the correct access rights
2496 error and the repository exists.
2497 verbose exit 128

但是,我已经使用ssh-keygen 添加了一个 ssh 密钥,并让 openssh 身份验证器服务自动运行。 (并将钥匙添加到钥匙串中)。

最初 git 本身也出现了问题,但是通过将 GIT_SSH 环境变量添加到用户环境变量来解决这个问题(将值作为窗口的 openssh 可执行文件的位置)。

每当我运行命令时

git --no-replace-objects ls-remote ssh://git@/P_0001_PI/config-loader.git

直接从命令行它可以工作(不要求输入密码,正如预期的那样)。但是在运行npm install 时会弹出上述错误。

【问题讨论】:

    标签: git npm ssh


    【解决方案1】:

    我想我迟到了,但以防万一有人看到:

    请在您的 repo 中打开您的 cmd 并运行 where ssh-agentwhere ssh-add 以测试首选的 ssh 路径。 如果一切设置正确,您应该会看到相同的路径。 如果您看到每个命令有多个路径,则首先出现的路径将是首选。 我有类似的问题,我设法在这里使用我的方法解决它:https://stackoverflow.com/a/63173335/14021241

    如果您认为您的方法也应该解决问题,只需确保在环境变量中以正确的顺序添加路径。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-06
      • 2019-05-29
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-25
      相关资源
      最近更新 更多