Config proxy for npm

The npm config files

The four relevant files are:
  • per-project config file (/path/to/my/project/.npmrc)
  • per-user config file (~/.npmrc)
  • global config file ($PREFIX/etc/npmrc)
  • npm builtin config file (/path/to/npm/npmrc)

Add the following entries in the config file:


proxy=http://proxy.company.com:8080
https-proxy=user:password@http://proxy.company.com:8080

npm 6 way for configuration,priority is listed as following order:

  1. Config parameter. --proxy http://server:port  It set proxy to: http://server:port.
  2. Environment variable。 npm_config_as the prefix for the environment variable will be recognized as the environment parameter for npm. For example, you can set proxy by: npm_config_proxy=http://server:port.
  3. User configuration document. Please enter npm config get userconfig to check the user config path。Mac default path for user is $HOME/.npmrc.
  4. Global configuration document. Please enternpm config get globalconfigto check the global configuration path. Mac default path for global configuration is /usr/local/etc/npmrc.
  5. Internal setting file. npmrc file which located in the npm installation directory.
  6. Default setting。 

 CLI Command

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://user:password@proxy.company.com:8080




留言

這個網誌中的熱門文章

Disable ionic's sidemenu content drag to toggle menu

Multiple writable mappings exist for the field. Only one may be defined as writable, all others must be specified read-only.

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser