#npm 更改全局安装包的默认位置#
背景:
npm install -g 模块 安装全局模块,默认安装到C 盘下,占用C盘资源
为了解决这个问题,需要修改默认的路径
1:查看默认路径
npm config get prefix
npm root -g
2:更新路径
npm config set prefix "D:\\npm"
3:查看默认缓存路径
npm config get cache
4:更新默认缓存
npm config set cache "D:\\npm\\npm-cache"
5:使用 npm 中国镜像
npm config set registry https://registry.npmmirror.com
6:查看镜像
npm config get registry
设置npm的环境变量,把npm默认安装的模块路径加入到path中,如图所示
加入环境变量以后可以解决一些问题,例如使用 grunt 工具 找不到路径问题