无法在 npm 依赖项中使用私有仓库

Unable to used private repo in npm dependencies

大家好 运行 npm install

时出现此错误
openssl config failed: error:02001002:system library:fopen:No such file or directory
openssl config failed: error:02001002:system library:fopen:No such file or directory
npm ERR! Error while executing:
npm ERR! C:\Users\rmittal\AppData\Local\Programs\Git\cmd\git.EXE ls-remote -h -t ssh://git@github.com/xxxx/xxx-api.git 
npm ERR!
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rmittal\AppData\Roaming\npm-cache\_logs21-04-02T06_15_51_313Z-debug.log

git@github.com/xxxx/xxx-api.git 只是我的另一个回购 我调查了 但并没有引导我找到解决方案。 有人可以帮助我吗?

使用的版本:

D:\>node -v
v10.23.1

D:\>npm -v
openssl config failed: error:02001002:system library:fopen:No such file or directory
openssl config failed: error:02001002:system library:fopen:No such file or directory
6.14.10

存储库也已正确设置

你提到的答案中建议的 ssh-keyscan -H github.com >> ~/.ssh/known_hosts 应该有效,但由于你在 CMD 中,它应该是:

ssh-keyscan -H github.com >> %USERPROFILE%/.ssh/known_hosts

假设:

  • 您的 %PATH% 包括 C:\path\to\Git\usr\binssh-keyscan.exe 所在的位置)
  • 您的私钥确实允许您访问该私有存储库。

在任何文件夹中用(独立于 npm)测试最后一点

 git ls-remote git@github.com/xxxx/xxx-api.git

如果您可以列出该私有存储库中的远程头,则意味着您确实可以访问它。如果需要,它应该要求在 %USERPROFILE%/.ssh/known_hosts 中添加指纹。

然后您可以再次尝试 npm 命令。