1.使用代理npm 安装某个module
https_proxy=http://代理地址 npm install module
2.设置configure
npmrc Files
The four relevant files are:
- per-project configuration file (
/path/to/my/project/.npmrc
) - per-user configuration file (defaults to
$HOME/.npmrc
; configurable via CLI option--userconfig
or environment variable$NPM_CONF_USERCONFIG
) - global configuration file (defaults to
$PREFIX/etc/npmrc
; configurable via CLI option--globalconfig
or environment variable$NPM_CONF_GLOBALCONFIG
) - npm's built-in configuration file (
/path/to/npm/npmrc
)
这是我的$HOME/.npmrc的简单配置
prefix = /usr/local # npm 地址 /usr/local/bin/npm
registry = http://registry.npm.taobao.org/ #淘宝镜像
strict-ssl = false # 不启用https
3. Default Configs 默认设置
Run npm config ls -l
to see a set of configuration parameters that are internal to npm, and are defaults if nothing else is specified.
npm config ls -l 查看配置 ,其中包括userconfig,default,globalconfig等配置
一般在$HOME/.npmrc 中修改内容.
https://docs.npmjs.com/misc/config罗列了一些默认值以及含义.