NPM gets the configuration in 6 ways, prioritized by high end.
command-line arguments. --proxy http://server:port
set the value of the proxy to http://server:port
.
Environment variables. The npm_config_
environment variables that are prefixed will be considered to be the configuration properties of NPM. If you set proxy, you can add such environment variables npm_config_proxy=http://server:port
.
The user configuration file. You can npm config get userconfig
view the file path by looking at it. If it is a Mac system, the default path is $HOME/.npmrc
.
Global configuration file. You can npm config get globalconfig
view the file path by looking at it. The default path for the Mac system is /usr/local/etc/npmrc
.
Built-in configuration files. Install the NPMRC file in the NPM directory.
Default configuration. NPM itself has default configuration parameters, and if none of the above 5 is set, NPM will use the default configuration parameters.
Set up a proxy for NPM?
12 |
$ npm config set proxy http: //server :port $ npm config set https-proxy http: //server :port |
This can be set if the agent requires authentication.
?
12 |
$ npm config set proxy http: //username :[email protected]:port $ npm config set https-proxy http: //username :[email protected]:port |
If the agent does not support HTTPS, you need to modify the website address of the NPM store package.
?
1 |
$ npm config set registry "http://registry.npmjs.org/" |
NPM Setup Agent