【问题标题】:npm install error: Could not read from remote repositorynpm 安装错误:无法从远程存储库读取
【发布时间】:2016-08-10 14:52:17
【问题描述】:

我尝试运行npm install -g polymer-cli,但每次运行它都会给我一个错误。

NPM 在为 git 和 npm 配置的公司代理后面运行。我安装 bower 或 gulp 没有问题,使用 git 克隆存储库也没有问题。

我试过这个没有结果: git config --global url."https://".insteadOf git:// 从这里 Stack Overflow - git:// protocol blocked by company, how can I get around that?

这是输出的一部分:

31725 error Windows_NT 6.1.7601
31726 error argv "C:\\Users\\user\Documents\\Tools\\node-v6.3.1-win-x64\\node.exe" "C:\\Users\\user\\Documents\\Tools\\node-v6.3.1-win-x64\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "polymer-cli"
31727 error node v6.3.1
31728 error npm  v3.10.5
31729 error code 128
31730 error Command failed: git -c core.longpaths=true clone --template=C:\Users\userAppData\Roaming\npm-cache\_git-remotes\_templates --mirror git@github.com:polymerelements/test-fixture.git C:\Users\user\AppData\Roaming\npm-cache\_git-remotes\git-github-com-polymerelements-test-fixture-git-8142662e
31730 error ssh: connect to host github.com port 22: Bad file number
31730 error fatal: Could not read from remote repository.
31730 error
31730 error Please make sure you have the correct access rights
31730 error and the repository exists.

【问题讨论】:

  • 在使用引号作为包名时出现此错误:npm install -g '@angular/cli' 而不是 npm install -g @angular/cli

标签: node.js git proxy npm polymer


【解决方案1】:

以管理员身份运行命令(打开 cmd 并以管理员身份运行)或在 linux 中以 sudo 身份运行。就我而言,它解决了问题。

【讨论】:

  • 我没有管理员权限,所以有问题。它是windows 7 x64 Enterprise机器。
  • 是的,问题出在权限上。要运行它,您必须以管理员身份运行 cmd。
【解决方案2】:

确保您的id_rsa 文件位于c:\users\$username\.ssh 文件夹中

配置 ssh-agent 程序以使用您的 SSH 密钥:
打开控制台并运行start-ssh-agent。它会找到您的id_rsa 并提示您输入passphrase

start-ssh-agent
Removing old ssh-agent sockets
Starting ssh-agent:  done
Enter passphrase for /c/Users/youruser/.ssh/id_rsa:
Identity added: /c/Users/youruser/.ssh/id_rsa (/c/Users/youruser/.ssh/id_rsa)

然后尝试再次运行npm install


注意:ssh-agent 也可能已经在运行:

start-ssh-agent
Found ssh-agent at 402860
Found ssh-agent socket at /tmp/ssh-YT2trepckpeN/agent.431360

在这种情况下,使用 ssh-add 它将找到您的 id_rsa 并提示您输入密码:

ssh-add
Enter passphrase for /c/Users/youruser/.ssh/id_rsa:
Identity added: /c/Users/youruser/.ssh/id_rsa (/c/Users/youruser/.ssh/id_rsa)

【讨论】:

  • start-ssh-agent 我无法识别,eval $(ssh-agent -s) 有效
猜你喜欢
  • 2017-09-07
  • 1970-01-01
  • 2013-04-13
  • 2019-11-02
  • 2020-11-03
  • 2016-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多