1.打开cmd命令行,查看当前配置
输入 npm config ls
先看一下当前npm的配置环境,由于我已经修改过,所以可以看到修改后的路径
2.修改路径
这里需要修改两个路径,module路径和cache路径
module对应prefix
cache对应cache
首先在别的盘新建两个目录
D:\nodejs\node_modules\npm\node_global_modules
D:\nodejs\node_modules\npm\node_cache
然后依次执行
npm config set prefix="D:\nodejs\node_modules\npm\node_global_modules"
npm config set cache="D:\nodejs\node_modules\npm\node_cache"