一、NPM
1.查询 npm 安装依赖的全局路径
npm prefix -g 2. 修改 npm 全局安装位置
npm config set prefix "D:\nodejs\node_modules\npm\node_modules" 3. 修改 npm 全局 cache 位置
npm config set cache "D:\nodejs\node_modules\npm\cache" 4. npm 修改后依赖安装
二、YARN
1. 查询 yarn 安装依赖的全局路径
yarn global bin 2. 修改 yarn 全局 bin 位置
yarn config set prefix "D:\nodejs\node_modules\yarn\bin" 3. 修改 yarn 全局安装位置
yarn config set global-folder "D:\nodejs\node_modules\yarn\node_modules" 4. 修改 yarn 全局 cache 位置
yarn config set cache-folder "D:\nodejs\node_modules\yarn\cache" 5. 修改 yarn 全局 link 位置
yarn config set link-folder "D:\nodejs\node_modules\yarn\datalink"