4

我尝试在 package.json 中设置 git 依赖项:

"dependencies": {
    "myLib": "git+ssh://git@domain.com:user/myLib.git"
  }

当我这样做时,sudo npm install我得到了错误:

Warning: Permanently added the RSA host key for IP address 'myIp' to the list of known hosts.

 Permission denied (publickey).

尽管我可以成功地将相同的库克隆到该机器:

git clone git@domain.com:user/myLib.git

所以我有有效的 ssh 密钥。

我的操作系统是OSX,但我在Linux上遇到了同样的问题。

4

4 回答 4

5

我应该在npm install没有sudo.

如果不能,则更改 node.js 应用程序文件夹的权限:

sudo chown -R `whoami` ~/pathToAll/node/apps.

所以 git ssh 依赖在 package.json 中运行良好

于 2013-07-08T07:04:59.780 回答
1

在 Windows 10 上解决了此问题的一种情况。

问题是我将我的 git bash ~ (home) 文件夹配置为c:\home并期望 git 找到c:\home.ssh文件夹,而当 git 从npm运行时,即使从 git bash 开始,git 使用C:\用户\.ssh

解决方案是将我的 .ssh 文件夹(包含我的 ssh 密钥)复制到 C:\Users\

于 2019-11-18T15:37:31.923 回答
0

这是一个允许继续使用的解决方案sudo npm install

将以下内容添加到文本文件中/root/.ssh/config

Host domain.com
    User git 
    Port 22
    Hostname domain.com
    IdentityFile "/home/user/.ssh/id_rsa"
    TCPKeepAlive yes 
    IdentitiesOnly yes 
    StrictHostKeyChecking no

即使在将sudo命令用于诸如sudo npm install.

于 2014-11-03T19:43:56.837 回答
0

避免使用 sudo npm install 而不是使用 npm install

*每当使用 github 存储库作为项目的依赖项时。

于 2018-06-07T12:02:58.620 回答