1、查看npm全局安装目录
npm config get prefix
2、设置npm全局安装路径
npm config set prefix "C:\Program Files\nodejs\node-global" npm config set cache "C:\Program Files\nodejs\node-cache"
3、设置npm镜像:
--持久使用,设置国内淘宝镜像
npm config set registry "https://registry.npm.taobao.org"
--临时使用,比如安装express
npm --registry https://registry.npm.taobao.org install express
--通过cnpm使用
npm install -g cnpm --registry=https://registry.npm.taobao.org