修改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意思是安裝到全局目錄下
安裝完畢後打開設置的安裝路徑看下是否成功
表示修改成功!