🚨

git protocol on port 9418 is no longer supported エラーの対処法

2022/04/24に公開

現象

■ node.jsのプロジェクトでnpm installしたところ以下のエラーが発生し、npm installに失敗した。

Error while executing:
npm ERR! /usr/local/bin/git ls-remote -h -t git://github.com/{hogehoge}.git
npm ERR!
npm ERR! fatal: remote error:
npm ERR!   The unauthenticated git protocol on port 9418 is no longer supported.
npm ERR! Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
npm ERR!
npm ERR! exited with error code: 128
.
.
.
ERR! The unauthenticated git protocol on port 9418 is no longer supported.
ERR! /usr/local/bin/git ls-remote -h -t git://github.com/{hogehoge}.git

上記エラー文が出力され、npm installに失敗してしまう。

原因

https://github.blog/2021-09-01-improving-git-protocol-security-github/

GitHubの推奨プロトコルがhttpsに変更、git始まりのurlは非推奨になっている。

On the Git protocol side, unencrypted git:// offers no integrity or authentication, making it subject to tampering. We expect very few people are still using this protocol, especially given that you can’t push (it’s read-only on GitHub). We’ll be disabling support for this protocol.

We’ll permanently stop accepting DSA keys. RSA keys uploaded after the cut-off point above will work only with SHA-2 signatures (but again, RSA keys uploaded before this date will continue to work with SHA-1). The deprecated MACs, ciphers, and unencrypted Git protocol will be permanently disabled.

2022年3月15日に廃止になった。
廃止になったgitプロトコルでgithubに接続しようと試みていたため、エラーになってしまう。

解決策

git://github.com/{hogehoge}.gitの部分をhttps化する

- git://github.com/{hogehoge}.git
+ https://github.com/{hogehoge}.git

Discussion