There are six methods for obtaining and configuring NPM, with the highest priority.
Command line parameters.-- Proxy http: // server: Port
Set the proxy valueHttp: // server: Port
.
Environment variable. ToNpm_config _
Environment variables with a prefix are considered as NPM configuration attributes. If you set proxy, you can add such environment variables.Npm_config_proxy = http: // server: Port
.
User configuration file. You can useNPM config get userconfig
View the file path. The default path is$ Home/. npmrc
.
Global configuration file. You can useNPM config get globalconfig
View the file path. The default path for Mac is/Usr/local/etc/npmrc
.
Built-in configuration file. Install the npmrc file in the NPM directory.
Default Configuration. NPM has default configuration parameters. If none of the above five items are set, NPM uses the default configuration parameters.
Set proxy for NPM?
12 |
$ NPM config Set Proxy http: // Server : Port $ NPM config Set Https-proxy http: // Server : Port |
If the proxy needs authentication, you can set it like this.
?
12 |
$ NPM config Set Proxy http: // Username : [Email protected]: Port $ NPM config Set Https-proxy http: // Username : [Email protected]: Port |
NPM obtains configuration and sets proxy