修改Nodejs内置的npm默认配置路径:
1. 打开cmd命令行,查看当前配置
输入 npm config ls
先看一下当前npm的配置环境
2. 修改路径
这里需要修改两个路径,module路径和cache路径
module对应prefix
cache对应cache
首先在别的盘新建两个目录
D:\nodejs\node_modules\npm\node_cache
D:\nodejs\node_modules\npm\node_global_modules
然后依次执行:
npm config set prefix=" D:\nodejs\node_modules\npm\node_global_modules "
npm config set cache=" D:\nodejs\node_modules\npm\node_cache "
3. 修改系统环境变量
新增系统环境变量 NODE_HOME
修改系统环境变量中Path,添加
D:\node\node_modules
D:\node\node_modules\npm
D:\node\node_modules\npm\node_cache
D:\node\node_modules\npm\node_global_modules
4. 查看下配置文件
执行命令:npm config ls
如果不是这样则修改.npmrc 配置文件
C:\Users\gao\.npmrc
5. 测试:
重新打开一个cmd命令行,安装插件
执行npm install -g @angular/cli
-g意思是安装到全局目录下
安装完毕后打开设置的安装路径看下是否成功
表示修改成功!