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

3

大家好, 当我运行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\_logs\2021-04-02T06_15_51_313Z-debug.log

git@github.com/xxxx/xxx-api.git 是我的另一个仓库。我查看了npm 安装错误:“Host key verification failed.",但没有找到解决方案。有人可以帮忙吗?

使用的版本:

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

仓库也已经正确设置。

1个回答

2

你提到的答案中建议使用 ssh-keyscan -H github.com >> ~/.ssh/known_hosts 命令,但由于你在 CMD 中,应该改为:

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

2023年3月警告:

"GitHub已更新其RSA SSH主机密钥"


假设:

  • 你的%PATH%包含C:\path\to\Git\usr\bin(其中包括ssh-keyscan.exe)
  • 你的私钥确实能让你访问那个私有仓库。

在任何文件夹中,独立于npm,可以使用以下命令测试最后一点:

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

如果您可以列出私有仓库的远程分支,那么这意味着您已经可以访问它。
如果需要的话,它应该要求在%USERPROFILE%/.ssh/known_hosts中添加指纹。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接