npmコマンドのproxy設定

iOSとAndroidのアプリのテストが自動でできるというappiumを試そうとしたときの話。

  • 環境
    • MacOS 10.9
  • インストール
$ brew install node
Warning: node-0.10.24 already installed
$ sudo npm install -g appium
Password:
npm http GET https://registry.npmjs.org/appium
npm http GET https://registry.npmjs.org/appium
npm http GET https://registry.npmjs.org/appium
npm ERR! network read ECONNRESET
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.	See: 'npm help config'
npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/Cellar/node/0.10.24/bin/node" "/usr/local/bin/npm" "install" "-g" "appium"
npm ERR! cwd /private/tmp
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR! syscall read
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!		 /private/tmp/npm-debug.log
npm ERR! not ok code 0

こんな感じでおこられてしまった

proxyの設定はbashの環境変数とは別の様でconfigで設定する必要が有ります

$ npm config set proxy http://proxyhost:8080

再度実行

$ sudo npm install -g appium
Password:
npm http GET https://registry.npmjs.org/appium
npm http 200 https://registry.npmjs.org/appium
npm http GET https://registry.npmjs.org/appium/-/appium-0.13.0.tgz
npm http 200 https://registry.npmjs.org/appium/-/appium-0.13.0.tgz
npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/argparse
npm http GET https://registry.npmjs.org/uuid-js
npm http GET https://registry.npmjs.org/rimraf
..