LoginSignup
57
52

More than 5 years have passed since last update.

npm でプロキシを設定/解除する

Posted at

プロキシを設定

  • proxy, https-proxy の設定をしてもエラーになる場合、registry を設定します。
  • npm -g config set で global に proxy, https-proxy, registry を設定します。
  • Windows環境で bat ファイル化する場合、npmコマンドがbatファイルなので「npm …」としてしまうと bat ファイルが終了してしまいます。npm の前に call を付けて「call npm …」としてください。コマンドプトからコマンドを叩くなら call は無くても良いです。

Linux

npm-set-proxy.sh
npm -g config set proxy "http://<server>:<port>/"
npm -g config set https-proxy "https://<server>:<port>/"
npm -g config set registry "http://registry.npmjs.org/"

Windows

npm-set-proxy.bat
call npm -g config set proxy "http://<server>:<port>/"
call npm -g config set https-proxy "https://<server>:<port>/"
call npm -g config set registry "http://registry.npmjs.org/"

プロキシを解除

  • npm -g config deleteで global の proxy, https-proxy, registry を削除します。
  • Windows 環境で bat ファイル化する場合は、npm の前に call を付けてください。コマンドプロンプトからコマンドを叩くなら call は無くても良いです。

Linux

npm-delete-proxy.sh
npm -g config delete proxy
npm -g config delete https-proxy
npm -g config delete registry

Windows

npm-delete-proxy.bat
call npm -g config delete proxy
call npm -g config delete https-proxy
call npm -g config delete registry

現在の設定を確認

  • 現在の設定を確認するには、npm -g config list します。
npm -g config list
57
52
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
57
52