npm常用配置

1.npm配置文件

npm有一个配置文件~/.npmrc,是一个key=value形式的文本文件,如

prefix=/home/czy/.nvm/node_global
cache=/home/czy/.nvm/node_cache

 

2.npm配置命令

使用npm config list来查看所有配置条目

使用npm config set xxx 'xxxxx'来配置指定条目

使用npm config get xxx 来获取指定条目

 

3.常用配置项目

 

3.1 prefix

npm config set prefix '/home/czy/.nvm/node_global'

用于配置npm全局安装路径,其下的全局安装脚本应该加入PATH

 

3.2 cache

npm config set cache '/home/czy/.nvm/node_cache'

用于配置npm安装缓存路径,比如下载的预编译文件等

 

3.3 registry

npm config set registry https://registry.npm.taobao.org
czy@Mint ~ $ npm config ls
cache = "/home/czy/.nvm/node_cache"
prefix = "/home/czy/.nvm/node_global"
registry = "https://registry.npm.taobao.org/"

用于配置npm安装包的来源,这里配置了淘宝镜像

 

3.4 disturl

npm config set disturl https://npm.taobao.org/dist

配置了一些静态文件的下载路径

 

3.5 electron_mirror

npm config set electron_mirror https://npm.taobao.org/mirrors/electron/

配置了electron的镜像目录

 

3.6 sass_binary_site

npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/

配置了node-sass预编译二进制文件下载目录

 

3.7 sharp_binary_host

npm config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"

sharp二进制文件下载

 

3.8 sharp_libvips_binary_host

npm config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"

sharp libvips库二进制文件下载

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章