【问题标题】:yarn fails during cloning repo: Permission denied (publickey)克隆回购期间纱线失败:权限被拒绝(公钥)
【发布时间】:2018-01-07 19:07:28
【问题描述】:

我正在尝试使用 Mac OS X 10.12 在我的桌面上本地构建这个项目:
https://github.com/lionsharecapital/lionshare-desktop

当我运行纱线时,我得到:

yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: clone ssh://git@github.com/prettier/prettier.git /Users/patrick/Library/Caches/Yarn/v1/.tmp/998d9289033d5404a23434d3979d79dc
Directory: /Users/patrick/dev/lionshare-desktop
Output:
Cloning into '/Users/patrick/Library/Caches/Yarn/v1/.tmp/998d9289033d5404a23434d3979d79dc'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

超级迷茫,我手动跑了git clone ssh://git@github.com/prettier/prettier.git /Users/patrick/Library/Caches/Yarn/v1/.tmp/998d9289033d5404a23434d3979d79d

而且效果很好......所以,当 yarn 使用 git 时,它没有使用我的全局 git 配置?

我该如何解决这个问题?

更新

奇怪的是,在另一台计算机上尝试这个没有这个问题,但是安装后,我按照他们的说明做了:

yarn run dev

但我明白了:

yarn run v0.27.5
$ concurrently -k 'node desktop/server.dev.js' 'npm start'
[1] module.js:487
[1]     throw err;
[1]     ^
[1]
[1] Error: Cannot find module 'update-notifier'
[1]     at Function.Module._resolveFilename (module.js:485:15)
[1]     at Function.Module._load (module.js:437:25)
[1]     at Module.require (module.js:513:17)
[1]     at require (internal/module.js:11:18)
[1]     at /usr/local/lib/node_modules/npm/bin/npm-cli.js:29:19
[1]     at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
[1]     at Module._compile (module.js:569:30)
[1]     at Object.Module._extensions..js (module.js:580:10)
[1]     at Module.load (module.js:503:32)
[1]     at tryModuleLoad (module.js:466:12)
[1] npm start exited with code 1
[0] listening on 3000
--> Sending SIGTERM to other processes..
[0] node desktop/server.dev.js exited with code null
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

第二次更新

显然,通过运行 yarn,我完全破坏了 npm,因为我发现如果我尝试对 npm 做任何事情,我会得到同样的错误:

>npm
module.js:487
    throw err;
    ^

Error: Cannot find module 'update-notifier'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:29:19
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)

这似乎是一场灾难!

更新 3

卸载节点并重新安装并没有解决这个问题,我不得不删除 ~/.npm 和 /usr/local/lib/node_modules,然后卸载节点并重新安装,现在 npm 又可以工作了……天哪……任何关于如何在不破坏我的开发环境的情况下构建这个项目的想法?

【问题讨论】:

    标签: git npm yarnpkg


    【解决方案1】:

    yarn install 使用 ssh-add 代理通过 GitHub 获取私有仓库。您可以绕过并手动运行git clone ssh://....,或者您可以将您的 ssh 密钥添加到 ssh-add。首先检查ssh key是否没有添加

    ssh-add -l
    

    这里必须显示一个key,如果显示agent没有身份,那么,你需要在这里添加你的ssh key。您可以使用添加

    ssh-add <path-to-ssh-key>
    

    这样就可以搞定了。

    【讨论】:

      【解决方案2】:

      yarnpkg PR 2384 (yarnpkg 0.19.0) 应该已经修复了 ssh URL 的任何问题。
      检查 URL 是否不应该是

      git+ssh://git@github.com:prettier/prettier.git
      

      另外,它似乎是一个公共 repo,所以你也可以尝试一个 https URL:你不需要身份验证来克隆所说的公共 repo。

      关于第二条错误信息,可以关注issue kraken-js/issues/79
      作为第一个解决方法:

      npm install -g update-notifier,
      

      【讨论】:

      • 我在另一台计算机上尝试了这个并且通过了 ssh 步骤就好了(奇怪),但是在尝试运行开发服务器时我得到了一个完全不同的错误,所以我更新了我的问题......
      • 使用 npm 为 yarn 项目安装依赖不是很奇怪吗?我的意思是,纱线的全部意义不在于它管理它需要的所有东西吗?
      猜你喜欢
      • 2016-02-20
      • 1970-01-01
      • 2023-01-14
      • 2017-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-23
      相关资源
      最近更新 更多