LoginSignup
202
190

More than 5 years have passed since last update.

proxy環境下でのnpm config設定

Last updated at Posted at 2014-01-15

proxy環境下でnpm install しようと思ったらハマったのでメモ。
まずは現在の設定を確認する。

$ npm config list

もっと詳しく見たい場合は以下を実行する。

$ npm config ls -l

proxyの設定

デフォルトでは環境変数のHTTP_PROXYhttp_proxyの値を見に行く。(設定していなければnull)
環境変数に設定せず、npmだけproxyを経由したい場合は以下のコマンドでproxyを設定する。もし環境変数を設定してある場合は、npm configで設定した値で上書きされる。

$ npm config set proxy http://proxy.example.com:8080

HTTPSの場合も同様。

$ npm config set https-proxy http://proxy.example.com:8080

詳細は以下を確認

レジストリ設定

以下のようにSSL関連でエラーが出た場合は

$ npm install express
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express
npm ERR! network tunneling socket could not be established, cause=7252:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:766:
npm ERR! network
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 Windows_NT 6.1.7601
npm ERR! command "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express"
npm ERR! cwd C:\Users\tenten0213\Documents\develop
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\tenten0213\Documents\develop\npm-debug.log
npm ERR! not ok code 

registryをhttpsからhttpに変更する。

$ npm config set registry http://registry.npmjs.org/

これでproxy環境下でもnpm install出来る。

202
190
3

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
202
190