1.打开cmd命令行,查看当前配置

输入 npm config ls

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

先看一下当前npm的配置环境,由于我已经修改过,所以可以看到修改后的路径

Linux下配置npm存放路径,解决权限问题 Linux 第1张Linux下配置npm存放路径,解决权限问题 Linux 第2张

 

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"

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄