yarn実行時 エラー「tunneling socket could not be established, statusCode=308」が発生した場合の対処法

yarn実行時 エラー「tunneling socket could not be established, statusCode=308」が発生した場合の対処法

yarn実行時 エラー「tunneling socket could not be established, statusCode=308」が発生した場合の対処法を記述してます。

環境

  • OS  Rocky Linux release 8.4 (Green Obsidian)
  • node v14.17.3
  • npm 7.19.1
  • yarn 1.22.10

エラー全文

以下のコマンド実行時に発生

$ npx create-react-app project_name

ネットワークがつながっていないっぽい

Creating a new React app in /home/testuser/project_name.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.22.10
[1/4] Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/react: tunneling socket could not be established, statusCode=308".
info If you think this is a bug, please open a bug report with the information provided in "/home/testuser/project_name/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts cra-template --cwd /home/testuser/project_name has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.

原因

ネットーワークには、問題なさそうだったが「http_proxy」に接続できない値が設定されていたため

$ echo ${http_proxy}

xxx.xxx.xxx.xxx ← ipアドレスだけが入っていた

対処法

破棄しても問題なさそうだったので「unset」する

$ unset http_proxy

再度、実行したところエラーは解消されました。