Npm
1.查看当前配置
打开cmd命令行,输入
npm config ls
2.修改路径
这里需要修改两个路径,module路径和cache路径
module对应prefix
cache对应cache
首先在别的盘新建两个目录
D:\nodejs\repository\npm\node_global
D:\nodejs\repository\npm\node_cache
然后依次执行
npm config set prefix="D:\nodejs\repository\npm\node_global"
npm config set cache="D:\nodejs\repository\npm\node_cache"
Yarn
1.查看当前配置
打开cmd命令行,输入
查看yarn的全局安装位置
yarn global dir
查看当前yarn的bin的位置
yarn global bin
yarn不是内部命令的问题
添加环境变量
Path中 添加 D:\nodejs\repository\npm\node_global,即通过npm安装组件的位置
2.修改路径
改变 yarn 全局安装位置
yarn config set global-folder "D:\nodejs\repository\yarn\node_global"
会在"我的用户"目录下找到".yarnrc"的文件,记录修改后的值
改变 yarn 缓存位置
yarn config set cache-folder "D:\nodejs\repository\yarn\node_cache"